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();
23 if (document.all) {browserType = "ie"}
24 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
27 var ns6=document.getElementById&&!document.all;
28 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
29 Event.observe(window, 'load', taskViewActivate);
30 Event.observe(window, 'load', fixbanner);
31 Event.observe(window, 'load', resizeViewport);
32 Event.observe(window, 'resize', resizeViewport);
33 //document.observe("dom:loaded", setupPrefEngine);
34 document.observe("dom:loaded", setupIconBar);
35 document.observe('dom:loaded', function() { if (!!document.getElementById("ib_chat_launch")) { $('ib_chat_launch').observe('click', launchChat); } });
36 function CtdlRandomString() {
37 return((Math.random()+'').substr(3));
40 function emptyElement(element) {
41 childNodes = element.childNodes;
42 for(var i=0; i<childNodes.length; i++) {
43 element.removeChild(childNodes[i]);
46 /** Implements superior internet explorer 'extract all child text from element' feature'. Falls back on buggy, patent violating standardized method */
47 function getTextContent(element) {
48 if (element.textContent == undefined) {
49 return element.innerText;
51 return element.textContent;
53 /** Same reasons as above */
54 function setTextContent(element, textContent) {
55 if(element.textContent == undefined) {
56 element.innerText = textContent;
58 element.textContent = textContent;
62 // We love string tokenizers.
63 function extract_token(source_string, token_num, delimiter) {
65 var extracted_string = source_string;
68 for (i=0; i<token_num; ++i) {
69 var j = extracted_string.indexOf(delimiter);
71 extracted_string = extracted_string.substr(j+1);
76 j = extracted_string.indexOf(delimiter);
78 extracted_string = extracted_string.substr(0, j);
81 return extracted_string;
84 function CtdlSpawnContextMenu(event, source) {
85 // remove any existing menus
86 disintergrateContextMenus(null);
87 var x = event.clientX-10; // cut a few pixels out so our mouseout works right
88 var y = event.clientY-10;
89 var contextDIV = document.createElement("div");
90 contextDIV.setAttribute("id", "ctdlContextMenu");
91 document.body.appendChild(contextDIV);
92 var sourceChildren = source.childNodes;
93 for(var j=0; j<sourceChildren.length; j++) {
94 contextDIV.appendChild(sourceChildren[j].cloneNode(true));
96 var leftRule = "left: "+x+"px;";
97 contextDIV.setAttribute("style", leftRule);
98 contextDIV.setAttribute("actual", leftRule);
99 contextDIV.style.top = y+"px";
100 contextDIV.style.display = "block";
101 $(contextDIV).observe('mouseout',disintergrateContextMenus);
103 function disintergrateContextMenus(event) {
104 var contextMenu = document.getElementById("ctdlContextMenu");
106 contextMenu.parentNode.removeChild(contextMenu);
108 Event.stopObserving(document,'click',disintergrateContextMenus);
110 // This code handles the popups for important-messages.
111 function hide_imsg_popup() {
112 if (browserType == "gecko") {
113 document.poppedLayer = eval('document.getElementById(\'important_message\')');
115 else if (browserType == "ie") {
116 document.poppedLayer = eval('document.all[\'important_message\']');
119 document.poppedLayer = eval('document.layers[\'`important_message\']');
122 document.poppedLayer.style.visibility = "hidden";
126 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
127 function activate_entmsg_autocompleters() {
128 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
129 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
130 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
133 function setupIconBar() {
134 if (!document.getElementById("switch")) {
137 _switchToRoomList = getTextContent(document.getElementById("rmlist_template"));
138 _switchToMenu = getTextContent(document.getElementById("mnlist_template"));
139 var switchSpan = document.getElementById("switch").firstChild;
140 if (switchSpan != null) {
141 setTextContent(switchSpan, _switchToRoomList);
142 $(switchSpan).observe('click', changeIconBarEvent);
143 var currentView = ctdlLocalPrefs.readPref("iconbar_view");
144 if (currentView != null) {
145 switchSpan.ctdlSwitchIconBarTo = currentView;
146 changeIconBar(switchSpan);
148 switchSpan.ctdlSwitchIconBarTo = "rooms";
151 var online_users = document.getElementById("online_users");
152 if (online_users.offsetParent != null && online_users.offsetTop > 0) {
153 new Ajax.PeriodicalUpdater('online_users', 'do_template?template=wholist_section', {method: 'get', frequency: 30});
156 function changeIconBarEvent(event) {
157 changeIconBar(event.target);
159 function changeIconBar(target) {
160 var switchTo = target.ctdlSwitchIconBarTo;
161 WCLog("Changing to: " + switchTo);
162 ctdlLocalPrefs.setPref("iconbar_view", target.ctdlSwitchIconBarTo);
163 if (switchTo == "rooms") {
164 switch_to_room_list();
165 setTextContent(target, _switchToMenu);
166 target.ctdlSwitchIconBarTo = "menu";
168 switch_to_menu_buttons();
169 setTextContent(target, _switchToRoomList);
170 target.ctdlSwitchIconBarTo = "rooms";
173 function switch_to_room_list() {
174 var roomlist = document.getElementById("roomlist");
175 var summary = document.getElementById("iconbar_menu");
176 if (!rooms || !floors || !roomlist) {
177 FillRooms(IconBarRoomList);
179 roomlist.className = roomlist.className.replace("hidden","");
180 summary.className += " hidden";
183 function switch_to_menu_buttons() {
184 if (roomlist != null) {
185 roomlist.className += "hidden";
187 var iconbar = document.getElementById("iconbar_menu");
188 iconbar.className = iconbar.className.replace("hidden","");
189 var roomlist = document.getElementById("roomlist");
190 roomlist.className += " hidden";
192 function IconBarRoomList() {
193 var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
194 currentDropTargets = new Array();
195 var iconbar = document.getElementById("iconbar");
196 roomlist = document.getElementById("roomlist");
197 var ul = document.createElement("ul");
198 roomlist.appendChild(ul);
199 // Add mailbox, because they are special
200 var mailboxLI = document.createElement("li");
201 ul.appendChild(mailboxLI);
202 var mailboxSPAN = document.createElement("span");
203 var _mailbox = getTextContent(document.getElementById("mbox_template"));
204 mailboxSPAN.appendChild(document.createTextNode(_mailbox));
205 $(mailboxSPAN).observe('click', expandFloorEvent);
206 mailboxLI.appendChild(mailboxSPAN);
207 mailboxLI.setAttribute("class", "floor");
208 var mailboxUL = document.createElement("ul");
209 mailboxLI.appendChild(mailboxUL);
210 var mailboxRooms = GetMailboxRooms();
211 for(var i=0; i<mailboxRooms.length; i++) {
212 var room = mailboxRooms[i];
213 currentDropTargets.push(addRoomToList(mailboxUL, room));
215 if (currentExpanded != null && currentExpanded == _mailbox ) {
216 expandFloor(mailboxSPAN);
218 for(var a=0; a<floors.length; a++) {
219 var floor = floors[a];
220 var floornum = floor[0];
222 var floorLI = document.createElement("li");
223 ul.appendChild(floorLI);
224 var floorSPAN = document.createElement("span");
225 floorSPAN.appendChild(document.createTextNode(name));
226 $(floorSPAN).observe('click', expandFloorEvent);
227 floorLI.appendChild(floorSPAN);
228 floorLI.setAttribute("class", "floor");
229 var floorUL = document.createElement("ul");
230 floorLI.appendChild(floorUL);
231 var roomsForFloor = GetRoomsByFloorNum(floornum);
232 for(var b=0; b<roomsForFloor.length; b++) {
233 var room = roomsForFloor[b];
234 currentDropTargets.push(addRoomToList(floorUL, room));
236 if (currentExpanded != null && currentExpanded == name) {
237 expandFloor(floorSPAN);
242 function addRoomToList(floorUL,room) {
243 var roomName = room[RN_ROOM_NAME];
244 var flag = room[RN_ROOM_FLAG];
245 var curView = room[RN_CUR_VIEW];
246 var view = room[RN_DEF_VIEW];
247 var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
248 var hasNewMsgs = ((curView & UA_HASNEWMSGS) == UA_HASNEWMSGS);
249 var roomLI = document.createElement("li");
250 var roomA = document.createElement("a");
251 roomA.setAttribute("href","dotgoto?room="+roomName);
252 roomA.appendChild(document.createTextNode(roomName));
253 roomLI.appendChild(roomA);
254 floorUL.appendChild(roomLI);
255 var className = "room ";
256 if (view == VIEW_MAILBOX) {
257 className += "room-private"
258 } else if (view == VIEW_ADDRESSBOOK) {
259 className += "room-addr";
260 } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
261 className += "room-cal";
262 } else if (view == VIEW_TASKS) {
263 className += "room-tasks";
264 } else if (view == VIEW_NOTES) {
265 className += "room-notes";
267 className += "room-chat";
270 className += " room-newmsgs";
272 roomLI.setAttribute("class", className);
273 roomA.dropTarget = true;
274 roomA.dropHandler = roomListDropHandler;
278 function roomListDropHandler(target, dropped) {
279 if (dropped.ctdlMsgId) {
280 var room = getTextContent(target);
282 for(msgId in currentlyMarkedRows) { //defined in summaryview.js
285 var mvCommand = "g_cmd=MOVE " + msgIds + "|"+room+"|0";
286 new Ajax.Request('ajax_servcmd', {
288 parameters: mvCommand,
289 onComplete: deleteAllMarkedRows()});
292 function expandFloorEvent(event) {
293 expandFloor(event.target);
295 function expandFloor(target) {
296 if (target.nodeName.toLowerCase() != "span") {
297 return; // ignore clicks on child UL
299 ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
300 var parentUL = target.parentNode;
301 if (currentlyExpandedFloor != null) {
302 currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
304 parentUL.className = parentUL.className + " floor-expanded";
305 currentlyExpandedFloor = parentUL;
308 // These functions handle moving sticky notes around the screen by dragging them
310 var uid_of_note_being_dragged = 0;
311 var saved_cursor_style = 'default';
312 var note_was_dragged = 0;
314 function NotesDragMouseUp(evt) {
315 document.onmouseup = null;
316 document.onmousemove = null;
317 if (document.layers) {
318 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
321 d = $('note-' + uid_of_note_being_dragged);
322 d.style.cursor = saved_cursor_style;
324 // If any motion actually occurred, submit an ajax http call to record it to the server
325 if (note_was_dragged > 0) {
326 p = 'note_uid=' + uid_of_note_being_dragged
327 + '&left=' + d.style.left
328 + '&top=' + d.style.top
329 + '&r=' + CtdlRandomString();
339 uid_of_note_being_dragged = '';
343 function NotesDragMouseMove(evt) {
344 x = (ns6 ? evt.clientX : event.clientX);
345 x_increment = x - saved_x;
346 y = (ns6 ? evt.clientY : event.clientY);
347 y_increment = y - saved_y;
350 d = $('note-' + uid_of_note_being_dragged);
352 divTop = parseInt(d.style.top);
353 divLeft = parseInt(d.style.left);
355 d.style.top = (divTop + y_increment) + 'px';
356 d.style.left = (divLeft + x_increment) + 'px';
360 note_was_dragged = 1;
365 function NotesDragMouseDown(evt, uid) {
366 saved_x = (ns6 ? evt.clientX : event.clientX);
367 saved_y = (ns6 ? evt.clientY : event.clientY);
368 document.onmouseup = NotesDragMouseUp;
369 document.onmousemove = NotesDragMouseMove;
370 if (document.layers) {
371 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
373 uid_of_note_being_dragged = uid;
374 d = $('note-' + uid_of_note_being_dragged);
375 saved_cursor_style = d.style.cursor;
376 d.style.cursor = 'move';
377 return false; // disable the default action
381 // Called when the user clicks on the palette icon of a sticky note to change its color.
382 // It toggles the color selector visible or invisible.
384 function NotesClickPalette(evt, uid) {
385 uid_of_note_being_colored = uid;
386 d = $('palette-' + uid_of_note_being_colored);
388 if (d.style.display) {
389 if (d.style.display == 'none') {
390 d.style.display = 'block';
393 d.style.display = 'none';
397 d.style.display = 'block';
404 // Called when the user clicks on one of the colors in an open color selector.
405 // Sets the desired color and then closes the color selector.
407 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
408 uid_of_note_being_colored = uid;
409 palette_button = $('palette-' + uid_of_note_being_colored);
410 note_div = $('note-' + uid_of_note_being_colored);
411 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
413 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
415 note_div.style.backgroundColor = notecolor;
416 titlebar_div.style.backgroundColor = titlecolor;
417 palette_button.style.display = 'none';
419 // submit an ajax http call to record it to the server
420 p = 'note_uid=' + uid_of_note_being_colored
424 + '&r=' + CtdlRandomString();
437 // These functions handle resizing sticky notes by dragging the resize handle
439 var uid_of_note_being_resized = 0;
440 var saved_cursor_style = 'default';
441 var note_was_resized = 0;
443 function NotesResizeMouseUp(evt) {
444 document.onmouseup = null;
445 document.onmousemove = null;
446 if (document.layers) {
447 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
450 d = $('note-' + uid_of_note_being_resized);
451 d.style.cursor = saved_cursor_style;
453 // If any motion actually occurred, submit an ajax http call to record it to the server
454 if (note_was_resized > 0) {
455 p = 'note_uid=' + uid_of_note_being_resized
456 + '&width=' + d.style.width
457 + '&height=' + d.style.height
458 + '&r=' + CtdlRandomString();
468 uid_of_note_being_resized = '';
469 return false; // disable the default action
472 function NotesResizeMouseMove(evt) {
473 x = (ns6 ? evt.clientX : event.clientX);
474 x_increment = x - saved_x;
475 y = (ns6 ? evt.clientY : event.clientY);
476 y_increment = y - saved_y;
479 d = $('note-' + uid_of_note_being_resized);
481 divTop = parseInt(d.style.height);
482 divLeft = parseInt(d.style.width);
484 d.style.height = (divTop + y_increment) + 'px';
485 d.style.width = (divLeft + x_increment) + 'px';
489 note_was_resized = 1;
490 return false; // disable the default action
494 function NotesResizeMouseDown(evt, uid) {
495 saved_x = (ns6 ? evt.clientX : event.clientX);
496 saved_y = (ns6 ? evt.clientY : event.clientY);
497 document.onmouseup = NotesResizeMouseUp;
498 document.onmousemove = NotesResizeMouseMove;
499 if (document.layers) {
500 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
502 uid_of_note_being_resized = uid;
503 d = $('note-' + uid_of_note_being_resized);
504 saved_cursor_style = d.style.cursor;
505 d.style.cursor = 'move';
506 return false; // disable the default action
510 function DeleteStickyNote(evt, uid, confirmation_prompt) {
511 uid_of_note_being_deleted = uid;
512 d = $('note-' + uid_of_note_being_deleted);
514 if (confirm(confirmation_prompt)) {
517 // submit an ajax http call to delete it on the server
518 p = 'note_uid=' + uid_of_note_being_deleted
520 + '&r=' + CtdlRandomString();
531 function ctdl_ts_getInnerText(el) {
532 if (typeof el == "string") return el;
533 if (typeof el == "undefined") { return el };
534 if (el.innerText) return el.innerText; //Not needed but it is faster
537 var cs = el.childNodes;
539 for (var i = 0; i < l; i++) {
540 switch (cs[i].nodeType) {
541 case 1: //ELEMENT_NODE
542 str += ts_getInnerText(cs[i]);
545 str += cs[i].nodeValue;
553 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
554 function CtdlLoadScreen(elementid) {
555 var elem = document.getElementById(elementid);
556 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>";
561 // Pop open the address book (target_input is the INPUT field to populate)
563 function PopOpenAddressBook(target_input) {
564 $('address_book_popup').style.display = 'block';
565 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
567 'address_book_popup_middle_div',
568 'display_address_book_middle_div',
577 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
578 $('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>";
579 p = 'which_addr_book=' + which_addr_book
580 + '&target_input=' + target_input
581 + '&r=' + CtdlRandomString();
583 'address_book_inner_div',
584 'display_address_book_inner_div',
592 // What happens when a contact is selected from the address book popup
593 // (populate the specified target)
595 function AddContactsToTarget(target, whichaddr) {
596 while (whichaddr.selectedIndex != -1) {
597 if (target.value.length > 0) {
598 target.value = target.value + ', ';
600 target.value = target.value + whichaddr.value;
601 whichaddr.options[whichaddr.selectedIndex].selected = false;
605 // Respond to a meeting invitation
606 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
607 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
608 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
609 Effect.Fade(question_divname, { duration: 0.5 });
612 // Handle a received RSVP
613 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
614 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
615 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
616 Effect.Fade(question_divname, { duration: 0.5 });
618 /* var fakeMouse = document.createEvent("MouseEvents");
619 fakeMouse.initMouseEvent("click", true, true, window,
620 0,0,0,0,0, false, false, false, false, 0, null); */
621 // TODO: Collapse into one function
622 function toggleTaskDtStart(event) {
623 var checkBox = $('nodtstart');
624 dtStart = document.getElementById("dtstart");
625 if (checkBox.checked) {
626 dtStart.disabled = true;
627 dtStart.style.textDecoration = "line-through";
629 dtStart.disabled = false;
630 dtStart.style.textDecoration = "";
631 if (dtStart.value.length == 0)
632 dtStart.dpck._initCurrentDate();
635 function toggleTaskDue(event) {
636 var checkBox = $('nodue');
637 dueField = document.getElementById("due");
638 if (checkBox.checked) {
639 dueField.disabled = true;
640 dueField.style.textDecoration = "line-through";
642 dueField.disabled = false;
643 dueField.style.textDecoration = "";
644 if (dueField.value.length == 0)
645 dueField.dpck._initCurrentDate();
648 function ToggleTaskDateOrNoDateActivate(event) {
649 var dtstart = document.getElementById("nodtstart");
650 if (dtstart != null) {
651 toggleTaskDtStart(null);
653 $('nodtstart').observe('click', toggleTaskDtStart);
654 $('nodue').observe('click', toggleTaskDue);
657 function TaskViewGatherCategoriesFromTable() {
658 var table = $('taskview');
661 function attachDatePicker(relative) {
662 var dpck = new DatePicker({
664 language: 'en', //wclang.substr(0,2),
665 disableFutureDate: false,
666 dateFormat: [ ["yyyy", "mm", "dd"], "-"],
669 document.getElementById(relative).dpck = dpck; // attach a ref to it
671 function eventEditAllDay() {
672 var allDayCheck = document.getElementById("alldayevent");
673 var dtend= document.getElementById("dtendcell");
674 if(allDayCheck.checked) {
675 //dtend.disabled = true;
676 dtend.style.textDecoration = "line-through";
678 //dtend_day.disabled = false;
679 dtend.style.textDecoration = "";
683 // Functions which handle show/hide of various elements in the recurrence editor
685 function RecurrenceShowHide() {
687 if ($('is_recur').checked) {
688 $('rrule_div').style.display = 'block';
691 $('rrule_div').style.display = 'none';
694 if ($('freq_selector').selectedIndex == 4) {
695 $('weekday_selector').style.display = 'block';
698 $('weekday_selector').style.display = 'none';
701 if ($('freq_selector').selectedIndex == 5) {
702 $('monthday_selector').style.display = 'block';
705 $('monthday_selector').style.display = 'none';
708 if ($('rrend_count').checked) {
709 $('rrcount').disabled = false;
712 $('rrcount').disabled = true;
715 if ($('rrend_until').checked) {
716 $('rruntil').disabled = false;
719 $('rruntil').disabled = true;
722 if ($('rrmonthtype_mday').checked) {
723 $('rrmday').disabled = false;
726 $('rrmday').disabled = true;
729 if ($('rrmonthtype_wday').checked) {
730 $('rrmweek').disabled = false;
731 $('rrmweekday').disabled = false;
734 $('rrmweek').disabled = true;
735 $('rrmweekday').disabled = true;
738 if ($('freq_selector').selectedIndex == 6) {
739 $('yearday_selector').style.display = 'block';
742 $('yearday_selector').style.display = 'none';
745 $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
746 $('rrmday').innerHTML = $('dtstart').value.substr(8);
748 if ($('rryeartype_ywday').checked) {
749 $('rrymweek').disabled = false;
750 $('rrymweekday').disabled = false;
751 $('rrymonth').disabled = false;
754 $('rrymweek').disabled = true;
755 $('rrymweekday').disabled = true;
756 $('rrymonth').disabled = true;
760 function launchChat(event) {
761 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
764 function WCLog(msg) {
765 if (!!window.console && !!console.log) {
767 } else if (!!window.opera && !!opera.postError) {
768 opera.postError(msg);
772 function fixMissingCSSTable(elems) {
773 if (elems[0] == null || elems[1] == null) {
776 if (elems[0].getStyle("display") != "table-cell") {
777 var parentNode = elems[0].parentNode;
778 var table = document.createElement("table");
779 table.style.width = "100%";
780 var tbody = document.createElement("tbody");
781 table.appendChild(tbody);
782 var tr = document.createElement("tr");
783 tbody.appendChild(tr);
784 parentNode.appendChild(table);
785 for(var i=0; i<elems.length; i++) {
786 parentNode.removeChild(elems[i]);
787 var td = document.createElement("td");
788 td.appendChild(elems[i]);
793 function fixbanner() {
794 // Use prototype api methods here
795 var elems = [$('room_banner'),$('actiondiv')];
796 fixMissingCSSTable(elems);
797 /* var banner = $('banner');
798 if (banner != null) {
802 function fixOffsetBanner() {
803 var banner = document.getElementById("banner");
804 if (banner.offsetLeft > 0) {
805 var viewportWidth = document.viewport.getWidth();
806 var iconbarWidth = document.getElementById("iconbar").offsetWidth;
807 var contentDiv = document.getElementById("content");
808 var newContentWidth = viewportWidth-iconbarWidth;
809 contentDiv.style.width = newContentWidth+"px";
812 /** Attempt to stop overflowing in x-axis in IE6 */
813 function resizeViewport() {
814 var documentWidth = 0;
815 var viewportWidth = document.viewport.getWidth();
816 var iconbar = $('iconbar');
817 var global = $('global');
818 if (typeof window.offsetWidth != 'undefined') {
819 documentWidth = window.offsetWidth;
821 documentWidth = document.documentElement.offsetWidth;
823 if (documentWidth > viewportWidth) {
824 WCLog("resizeViewport");
825 document.documentElement.style.width = viewportWidth+"px";
826 document.documentElement.style.overflowX = "hidden";
827 //viewportWidth = 0.98 * viewportWidth;
828 var newIconBarSize = 0.16 * viewportWidth;
829 var newContentSize = viewportWidth - newIconBarSize;
830 iconbar.style.width = newIconBarSize+"px";
831 global.style.width = newContentSize+"px";