steffen: server/kolab-horde-fbview/kolab-horde-fbview/fbview/templates/javascript enter_key_trap.js, NONE, 1.1 form_helpers.js, NONE, 1.1 form_sections.js, NONE, 1.1 htmlarea.js, NONE, 1.1 htmlarea_lang.js, NONE, 1.1 image.js, NONE, 1.1 menu.js, NONE, 1.1 open_calendar.js, NONE, 1.1 open_colorpicker.js, NONE, 1.1 open_google_win.js, NONE, 1.1 open_help_win.js, NONE, 1.1 open_html_helper.js, NONE, 1.1 open_print_win.js, NONE, 1.1 open_share_edit_win.js, NONE, 1.1 popup.js, NONE, 1.1 print.js, NONE, 1.1 sorter.js, NONE, 1.1 tooltip.js, NONE, 1.1 tree.js, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Mon Oct 31 12:43:36 CET 2005


Author: steffen

Update of /kolabrepository/server/kolab-horde-fbview/kolab-horde-fbview/fbview/templates/javascript
In directory doto:/tmp/cvs-serv18388/kolab-horde-fbview/kolab-horde-fbview/fbview/templates/javascript

Added Files:
	enter_key_trap.js form_helpers.js form_sections.js htmlarea.js 
	htmlarea_lang.js image.js menu.js open_calendar.js 
	open_colorpicker.js open_google_win.js open_help_win.js 
	open_html_helper.js open_print_win.js open_share_edit_win.js 
	popup.js print.js sorter.js tooltip.js tree.js 
Log Message:
Fbview in separate package

--- NEW FILE: enter_key_trap.js ---
/**
 * Javascript to trap for the enter key.
 *
 * $Horde: horde/templates/javascript/enter_key_trap.js,v 1.1 2003/10/23 22:05:27 mdjukic Exp $
 *
 * See the enclosed file COPYING for license information (LGPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @version $Revision: 1.1 $
 * @package horde
 */

function enter_key_trap(e)
{
    var keyPressed;

    if (document.layers) {
        keyPressed = String.fromCharCode(e.which);
    } else if (document.all) {
        keyPressed = String.fromCharCode(window.event.keyCode);
    } else if (document.getElementById) {
        keyPressed = String.fromCharCode(e.keyCode);
    }

    return (keyPressed == "\r" || keyPressed == "\n");
}

--- NEW FILE: form_helpers.js ---
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
/**
 * Javascript to add events to form elements
 *
 * Copyright 2004 Matt Kynaston <matt at kynx.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Matt Kynaston <matt at kynx.org>
 * @package Horde
 */

/**
 * Adds the given event to an element. If the element already has script for
 * the event, the new event is appended.
 * 
 * @param       Element         obj             the element to add event to
 * @param       string          name            the name of the event
 * @param       string          onchange        the onchange javascript 
 */
function addEvent(obj, name, js)
{
    if (obj) {
        // get existing events
        eval('events = obj.' + name);
        events = (events) ? events.toString() : '';
        events = events.substring(
                    events.indexOf('{') + 1, 
                    events.lastIndexOf('}'));
        events = events.replace(/\n/g, '').split(';');
        
        // return events should always be last, and are overridden
        // by any added ones, so always return a Macromedia-style 
        // document.MM_retVal
        count = events.length;
        last = '';
        while (last == '') {
            last = events.pop();
            count--;
        }
        is_return = (last.indexOf('return ') != -1);
        if (js.indexOf('return ') != -1 && is_return) {
            events.push(js);
        }
        else {
            if (is_return) {
                events.push(js);
                events.push(last);
            }
            else {
                events.push(last);
                events.push(js);
            }
        }
        
        js = events.join(';'); 

        // assign new anonymous function to event
        func = new Function(js);
        return eval('obj.' + name + '=func'); 
    }
    else {
        return false;
    }
}

/**
 * Returns given value as a number, or zero if NaN
 * @param       mixed   val
 * @return      Number
 */
function toNumber(val) 
{
    if (isNaN(val)) {
        return 0;
    }
    else {
        return Number(val);
    }
}

/**
 * Sets the enabled state of one element based on the values of another
 * 
 * Takes four or more arguments, in the form...
 *   checkEnabled(source, target, true, value1, value2, value3...)
 *
 * @param   Element    src      the element to check
 * @param   string     target   the element to enable/disable
 * @param   boolean    enabled  whether to enable or disable the target
 * @param   mixed               the value to check against
 */
function checkEnabled() 
{
    if (arguments.length > 2) {
        objSrc = arguments[0];
        objTarget = objSrc.form.elements[arguments[1]];
        enabled = arguments[2];
        toggle = false;
        if (objTarget) {
            switch (objSrc.type.toLowerCase()) {
                case 'select-one' :
                    val = objSrc.options[objSrc.selectedIndex].value;
                    break;
                case 'select-multiple' :
                    val = new Array();
                    count = 0;
                    for (i=0; i<objSrc.length; i++) {
                        if (objSrc.options[i].selected) {
                            val[count] = objSrc.options[i].value;
                        }
                    }
                    break;
                case 'checkbox' :
                    if (objSrc.checked) {
                        val = objSrc.value;
                        toggle = true;
                    }
                default :
                    val = objSrc.value;
            }
            for (i=3; i<arguments.length; i++) {
                if (typeof(val) == 'object' && (arguments[i] in val)) {
                    toggle = true;
                    break;
                }
                else if (arguments[i] == val) {
                    toggle = true;
                    break;
                }
            }
            
            objTarget.disabled = (toggle) ? !enabled : enabled;
            if (!objTarget.disabled) {
                // objTarget.focus();
            }
        }
    }
}

/**
 * Sets the target field to the sum of a range of fields 
 *
 * Takes three or more arguments, in the form:
 *    sumFields(form, target, field1, field2, field3...)
 * @param       Form            objFrm          the form to check
 * @param       string          target          the name of the target element
 * @param       string                          one or more field names to sum
 */
function sumFields() 
{
    if (arguments.length > 2) {
        objFrm = arguments[0];
        objTarget = objFrm.elements[arguments[1]];
        sum = 0;
        if (objTarget) {
            for (i=2; i<arguments.length; i++) {
                objSrc = objFrm.elements[arguments[i]];
                if (objSrc) {
                    switch (objSrc.type.toLowerCase()) {
                        case 'select-one':
                            sum += toNumber(objSrc.options[objSrc.selectedIndex].value);
                            break;
                        case 'select-multiple' :
                            for (j=0; j<objSrc.length; j++) {
                                sum += toNumber(objSrc.options[j].value);
                            }
                            break;
                        case 'checkbox' :
                            if (objSrc.checked) {
                                sum += toNumber(objSrc.value);
                            }
                            break;
                        default :
                            sum += toNumber(objSrc.value);
                    }
                }
            }
            objTarget.value = sum;
        }
    }
}

--- NEW FILE: form_sections.js ---
/**
 * Horde Form Sections Javascript Class
 *
 * Provides the javascript class for handling tabbed sections in Horde Forms.
 *
 * Copyright 2003-2004 Marko Djukic <marko at oblo.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * $Horde: horde/templates/javascript/form_sections.js,v 1.6 2004/03/16 19:20:36 chuck Exp $
 *
 * @author  Marko Djukic <marko at oblo.com>
 * @version $Revision: 1.1 $
 * @package Horde_Form
 */
function Horde_Form_Sections(instanceName, openSection)
{
    /* Set up this class instance for function calls from the page. */
    this._instanceName = instanceName;

    /* Store the currently open section in a variable, as well as the
     * cookie. */
    this._openSection = openSection;

    /* The cookie name we'll use. */
    this._cookieName = this._instanceName + '_open';

    this.getThis = function()
    {
        return this;
    }

    this.toggle = function(sectionId)
    {
        /* Get the currently open section object. */
        openSectionId = this._get();
        if (document.getElementById('_section_' + openSectionId)) {
            document.getElementById('_section_' + openSectionId).style.display = 'none';
            document.getElementById('_tab_' + openSectionId).className = 'tab';
            document.getElementById('_tabLink_' + openSectionId).className = 'tab';
        }

        /* Get the newly opened section object. */
        if (document.getElementById('_section_' + sectionId)) {
            document.getElementById('_section_' + sectionId).style.display = 'block';
            document.getElementById('_tab_' + sectionId).className = 'tab-hi';
            document.getElementById('_tabLink_' + sectionId).className = 'tab-hi';
        }

        /* Store the newly opened section. */
        this._set(sectionId);
    }

    this._get = function()
    {
        var dc = document.cookie;
        var prefix = this._cookieName + '=';
        var begin = dc.indexOf('; ' + prefix);
        if (begin == -1) {
            begin = dc.indexOf(prefix);
            if (begin != 0) {
                return this._openSection;
            }
        } else {
            begin += 2;
        }

        var end = dc.indexOf(';', begin);
        if (end == -1) {
            end = dc.length;
        }

        return unescape(dc.substring(begin + prefix.length, end));
    }

    this._set = function(sectionId)
    {
        var cookieValue = this._cookieName + '=' + escape(sectionId);
        cookieValue += ';DOMAIN=<?php echo $GLOBALS['conf']['cookie']['domain'] ?>;PATH=<?php echo $GLOBALS['conf']['cookie']['path'] ?>;';
        document.cookie = cookieValue;
        this._openSection = sectionId;
    }

    this._set(openSection);
}

--- NEW FILE: htmlarea.js ---
var _editor_url = "<?php echo $GLOBALS['registry']->getParam('webroot', 'horde') ?>/services/editor/htmlarea/";
--- NEW FILE: htmlarea_lang.js ---
HTMLArea.I18N = {

	// the following should be the filename without .js extension
	// it will be used for automatically load plugin language.
	lang: "en",

	tooltips: {
		bold:           "<?php echo addslashes(_("Bold")) ?>",
		italic:         "<?php echo addslashes(_("Italic")) ?>",
		underline:      "<?php echo addslashes(_("Underline")) ?>",
		strikethrough:  "<?php echo addslashes(_("Strikethrough")) ?>",
		subscript:      "<?php echo addslashes(_("Subscript")) ?>",
		superscript:    "<?php echo addslashes(_("Superscript")) ?>",
		justifyleft:    "<?php echo addslashes(_("Justify Left")) ?>",
		justifycenter:  "<?php echo addslashes(_("Justify Center")) ?>",
		justifyright:   "<?php echo addslashes(_("Justify Right")) ?>",
		justifyfull:    "<?php echo addslashes(_("Justify Full")) ?>",
		orderedlist:    "<?php echo addslashes(_("Ordered List")) ?>",
		unorderedlist:  "<?php echo addslashes(_("Bulleted List")) ?>",
		outdent:        "<?php echo addslashes(_("Decrease Indent")) ?>",
		indent:         "<?php echo addslashes(_("Increase Indent")) ?>",
		forecolor:      "<?php echo addslashes(_("Font Color")) ?>",
		hilitecolor:    "<?php echo addslashes(_("Background Color")) ?>",
		horizontalrule: "<?php echo addslashes(_("Horizontal Rule")) ?>",
		createlink:     "<?php echo addslashes(_("Insert Web Link")) ?>",
		insertimage:    "<?php echo addslashes(_("Insert/Modify Image")) ?>",
		inserttable:    "<?php echo addslashes(_("Insert Table")) ?>",
		htmlmode:       "<?php echo addslashes(_("Toggle HTML Source")) ?>",
		popupeditor:    "<?php echo addslashes(_("Enlarge Editor")) ?>",
		about:          "<?php echo addslashes(_("About this editor")) ?>",
		showhelp:       "<?php echo addslashes(_("Help using editor")) ?>",
		textindicator:  "<?php echo addslashes(_("Current style")) ?>",
		undo:           "<?php echo addslashes(_("Undoes your last action")) ?>",
		redo:           "<?php echo addslashes(_("Redoes your last action")) ?>",
		cut:            "<?php echo addslashes(_("Cut selection")) ?>",
		copy:           "<?php echo addslashes(_("Copy selection")) ?>",
		paste:          "<?php echo addslashes(_("Paste from clipboard")) ?>",
		lefttoright:    "<?php echo addslashes(_("Direction left to right")) ?>",
		righttoleft:    "<?php echo addslashes(_("Direction right to left")) ?>"
	},

	buttons: {
		"ok":           "<?php echo addslashes(_("OK")) ?>",
		"cancel":       "<?php echo addslashes(_("Cancel")) ?>"
	},

	msg: {
		"Path":         "<?php echo addslashes(_("Path")) ?>",
		"TEXT_MODE":    "<?php echo addslashes(_("You are in TEXT MODE.  Use the [<>] button to switch back to WYSIWYG.")) ?>",

		"IE-sucks-full-screen" :
		// translate here
		"<?php echo addslashes(_("The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren't able to workaround.  You might experience garbage display, lack of editor functions and/or random browser crashes.  If your system is Windows 9x it's very likely that you'll get a 'General Protection Fault' and need to reboot.\\n\\nYou have been warned.  Please press OK if you still want to try the full screen editor.")) ?>",

		"Moz-Clipboard" :
		"<?php echo addslashes(_("Unprivileged scripts cannot access Cut/Copy/Paste programatically for security reasons.  Click OK to see a technical note at mozilla.org which shows you how to allow a script to access the clipboard.")) ?>"
	},

	dialogs: {
		"Cancel"                                            : "<?php echo addslashes(_("Cancel")) ?>",
		"Insert/Modify Link"                                : "<?php echo addslashes(_("Insert/Modify Link")) ?>",
		"New window (_blank)"                               : "<?php echo addslashes(_("New window (_blank)")) ?>",
		"None (use implicit)"                               : "<?php echo addslashes(_("None (use implicit)")) ?>",
		"OK"                                                : "<?php echo addslashes(_("OK")) ?>",
		"Other"                                             : "<?php echo addslashes(_("Other")) ?>",
		"Same frame (_self)"                                : "<?php echo addslashes(_("Same frame (_self)")) ?>",
		"Target:"                                           : "<?php echo addslashes(_("Target:")) ?>",
		"Title (tooltip):"                                  : "<?php echo addslashes(_("Title (tooltip):")) ?>",
		"Top frame (_top)"                                  : "<?php echo addslashes(_("Top frame (_top)")) ?>",
		"URL:"                                              : "<?php echo addslashes(_("URL:")) ?>",
		"You must enter the URL where this link points to"  : "<?php echo addslashes(_("You must enter the URL where this link points to")) ?>"
	}
};

--- NEW FILE: image.js ---
/**
 * Horde Image Javascript
 *
 * Provides the javascript to help during the uploading of images in Horde_Form.
 *
 * $Horde: horde/templates/javascript/image.js,v 1.3 2004/01/01 16:17:43 jan Exp $
 *
 * Copyright 2003-2004 Marko Djukic <marko at oblo.com>
 *
 * See the enclosed file COPYING for license information (GPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * @author Marko Djukic <marko at oblo.com>
 * @version $Revision: 1.1 $
 * @package horde
 */

/**
 * Changes the src of an image target, optionally attaching a time value to the
 * URL to make sure that the image does update and not use the browser cache.
 *
 * @param string src              The srouce to inserted into the image element.
 * @param string target           The target element.
 * @param optional bool no_cache  If set to true will append the time.
 *
 * @return bool  False to stop the browser loading anything.
 */
function showImage(src, target, no_cache)
{
    var img = document.getElementById(target);
    if (no_cache == undefined) {
        var no_cache = false;
    }

    if (no_cache) {
        var now = new Date();
        src = src + '<?php echo ini_get('arg_separator.output') ?>' + now.getTime();
    }

    img.src = src;

    return false;
}

/**
 * Adds to the given source the height/width field values for the given target.
 *
 * @param string src           The srouce to append to the resize params.
 * @param string target        The target element.
 * @param optional bool ratio  If set to true will append fix the ratio.
 *
 * @return string  The modified source to include the resize data.
 */
function getResizeSrc(src, target, ratio)
{
    var width = document.getElementById('_w_' + target).value;
    var height = document.getElementById('_h_' + target).value;
    if (ratio == undefined) {
        var ratio = 0;
    }

    src = src + '<?php echo ini_get('arg_separator.output') ?>' + 'v=' + width + '.' + height + '.' + ratio;

    return src;
}

--- NEW FILE: menu.js ---
function correctWidthForScrollbar()
{
<?php if ($GLOBALS['browser']->hasQuirk('scrollbar_in_way')): ?>
    // Correct for frame scrollbar in IE by determining if a scrollbar is present,
    // and if not readjusting the marginRight property to 0
    // See http://www.xs4all.nl/~ppk/js/doctypes.html for why this works
    if (document.documentElement.clientHeight == document.documentElement.offsetHeight) {
        // no scrollbar present, take away extra margin
        document.body.style.marginRight = '0px';
    } else {
        document.body.style.marginRight = '15px';
    }
<?php endif; ?>
}

<?php if ($GLOBALS['browser']->hasFeature('dom')): ?>
var shown = new Array();

document.write('<style type="text/css">');
document.write('.para {display: none}');
document.write('</style>');

function toggle(i)
{
    shown[i] = shown[i] ? shown[i] : false;
    shown[i] = !shown[i];
    var current = shown[i] ? 'block' : 'none';
    var state = shown[i] ? 'expanded' : 'collapsed';

    if (document.getElementById && document.getElementById('menu_' + i)) {
        document.getElementById('menu_' + i).style.display = current;
        document.getElementById('arrow_' + i).src = '<?php echo $GLOBALS['registry']->getParam('graphics', 'horde') . '/tree/arrow-' ?>' + state + '.gif';
    } else if (document.all && document.all['menu_' + i]) {
        document.all['menu_' + i].style.display = current;
        document.all['arrow_' + i].src = '<?php echo $GLOBALS['registry']->getParam('graphics', 'horde') . '/tree/arrow-' ?>' + state + '.gif';
    }

    correctWidthForScrollbar();
}
<?php else: ?>
function toggle(i)
{
    return false;
}
<?php endif; ?>

--- NEW FILE: open_calendar.js ---
var currentDate, currentYear, curImgId;

function openCalendar(imgId, target, callback)
{
    if (document.getElementById(target + '[year]').value && document.getElementById(target + '[month]').value && document.getElementById(target + '[day]').value) {
        var d = new Date(document.getElementById(target + '[year]').value,
                         document.getElementById(target + '[month]').value - 1,
                         document.getElementById(target + '[day]').value);
    } else {
        var d = new Date();
    }

    var e = d;

    openGoto(d.getTime(), imgId, target, callback);
}

function openGoto(timestamp, imgId, target, callback)
{
    var row, cell, img, link, days;

    var d = new Date(timestamp);
    currentDate = d;
    var month = d.getMonth();
    var year = d.getYear();
    if (year < 1900) {
        year += 1900;
    }
    currentYear = year;
    var firstOfMonth = new Date(year, month, 1);
    var diff = firstOfMonth.getDay() - 1;
    if (diff == -1) {
        diff = 6;
    }
    switch (month) {
    case 3:
    case 5:
    case 8:
    case 10:
        days = 30;
        break;

    case 1:
        if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
            days = 29;
        } else {
            days = 28;
        }
        break;

    default:
        days = 31;
        break;
    }

    var wdays = [
        '<?php echo _("Mo") ?>',
        '<?php echo _("Tu") ?>',
        '<?php echo _("We") ?>',
        '<?php echo _("Th") ?>',
        '<?php echo _("Fr") ?>',
        '<?php echo _("Sa") ?>',
        '<?php echo _("Su") ?>'
    ];
    var months = [
        '<?php echo _("January") ?>',
        '<?php echo _("February") ?>',
        '<?php echo _("March") ?>',
        '<?php echo _("April") ?>',
        '<?php echo _("May") ?>',
        '<?php echo _("June") ?>',
        '<?php echo _("July") ?>',
        '<?php echo _("August") ?>',
        '<?php echo _("September") ?>',
        '<?php echo _("October") ?>',
        '<?php echo _("November") ?>',
        '<?php echo _("December") ?>'
    ];

    var layer = document.getElementById('goto');
    if (layer.firstChild) {
        layer.removeChild(layer.firstChild);
    }

    var table = document.createElement('TABLE');
    var tbody = document.createElement('TBODY');
    table.appendChild(tbody);
    table.className = 'item';
    table.cellSpacing = 0;
    table.cellPadding = 2;
    table.border = 0;

    // Title bar.
    row = document.createElement('TR');
    cell = document.createElement('TD');
    cell.colSpan = 7;
    cell.align = 'right';
    cell.className = 'header';
    link = document.createElement('A');
    link.onclick = function() {
        var layer = document.getElementById('goto');
        layer.style.visibility = 'hidden';
        if (layer.firstChild) {
            layer.removeChild(layer.firstChild);
        }
        return false;
    }
    img = document.createElement('IMG')
    img.src = '<?php echo $GLOBALS['registry']->getParam('graphics', 'horde') ?>/close.gif';
    img.border = 0;
    link.appendChild(img);
    cell.appendChild(link);
    row.appendChild(cell);
    tbody.appendChild(row);

    // Year.
    row = document.createElement('TR');
    cell = document.createElement('TD');
    cell.align = 'left';
    link = document.createElement('A');
    link.onclick = function() {
        newDate = new Date(currentYear - 1, currentDate.getMonth(), currentDate.getDate());
        openGoto(newDate.getTime(), imgId, target, callback);
        return false;
    }
    cell.appendChild(link);
    img = document.createElement('IMG')
    img.src = '<?php echo $GLOBALS['registry']->getParam('graphics', 'horde') ?>/nav/left.gif';
    img.align = 'middle';
    img.border = 0;
    link.appendChild(img);
    row.appendChild(cell);

    cell = document.createElement('TD');
    cell.colSpan = 5;
    cell.align = 'center';
    var y = document.createTextNode(year);
    cell.appendChild(y);
    row.appendChild(cell);

    cell = document.createElement('TD');
    cell.align = 'right';
    link = document.createElement('A');
    link.onclick = function() {
        newDate = new Date(currentYear + 1, currentDate.getMonth(), currentDate.getDate());
        openGoto(newDate.getTime(), imgId, target, callback);
        return false;
    }
    cell.appendChild(link);
    img = document.createElement('IMG')
    img.src = '<?php echo $GLOBALS['registry']->getParam('graphics', 'horde') ?>/nav/right.gif';
    img.align = 'middle';
    img.border = 0;
    link.appendChild(img);
    row.appendChild(cell);
    tbody.appendChild(row);

    // Month name.
    row = document.createElement('TR');
    cell = document.createElement('TD');
    cell.align = 'left';
    link = document.createElement('A');
    link.onclick = function() {
        newDate = new Date(currentYear, currentDate.getMonth() - 1, currentDate.getDate());
        openGoto(newDate.getTime(), imgId, target, callback);
        return false;
    }
    cell.appendChild(link);
    img = document.createElement('IMG')
    img.src = '<?php echo $GLOBALS['registry']->getParam('graphics', 'horde') ?>/nav/left.gif';
    img.align = 'middle';
    img.border = 0;
    link.appendChild(img);
    row.appendChild(cell);

    cell = document.createElement('TD');
    cell.colSpan = 5;
    cell.align = 'center';
    var m = document.createTextNode(months[month]);
    cell.appendChild(m);
    row.appendChild(cell);

    cell = document.createElement('TD');
    cell.align = 'right';
    link = document.createElement('A');
    link.onclick = function() {
        newDate = new Date(currentYear, currentDate.getMonth() + 1, currentDate.getDate());
        openGoto(newDate.getTime(), imgId, target, callback);
        return false;
    }
    cell.appendChild(link);
    img = document.createElement('IMG')
    img.src = '<?php echo $GLOBALS['registry']->getParam('graphics', 'horde') ?>/nav/right.gif';
    img.align = 'middle';
    img.border = 0;
    link.appendChild(img);
    row.appendChild(cell);
    tbody.appendChild(row);

    // Weekdays.
    row = document.createElement('TR');
    for (var i = 0; i < 7; i++) {
        cell = document.createElement('TD');
        weekday = document.createTextNode(wdays[i]);
        cell.appendChild(weekday);
        row.appendChild(cell);
    }
    tbody.appendChild(row);

    // Rows.
    var week, italic;
    var count = 1;
    var today = new Date();
    var thisYear = today.getYear();
    if (thisYear < 1900) {
        thisYear += 1900;
    }

    var odd = true;
    for (var i = 1; i <= days; i++) {
        if (count == 1) {
            row = document.createElement('TR');
            row.align = 'right';
            if (odd) {
                row.className = 'item0';
            } else {
                row.className = 'item1';
            }
            odd = !odd;
        }
        if (i == 1) {
            for (var j = 0; j < diff; j++) {
                cell = document.createElement('TD');
                row.appendChild(cell);
                count++;
            }
        }
        cell = document.createElement('TD');
        if (thisYear == year &&
            today.getMonth() == month &&
            today.getDate() == i) {
            cell.style.border = '1px solid red';
        }

        link = document.createElement('A');
        cell.appendChild(link);

        link.href = i;
        link.onclick = function() {
            var day = this.href;
            while (day.indexOf('/') != -1) {
                day = day.substring(day.indexOf('/') + 1);
            }

            document.getElementById(target + '[month]').value = month + 1;
            document.getElementById(target + '[day]').value = day;
            document.getElementById(target + '[year]').value = year;

            var layer = document.getElementById('goto');
            layer.style.visibility = 'hidden';
            if (layer.firstChild) {
                layer.removeChild(layer.firstChild);
            }

            if (callback) {
                eval(callback);
            }

            return false;
        }

        day = document.createTextNode(i);
        link.appendChild(day);

        row.appendChild(cell);
        if (count == 7) {
            tbody.appendChild(row);
            count = 0;
        }
        count++;
    }
    if (count > 1) {
        for (i = count; i <= 7; i++) {
            cell = document.createElement('TD');
            row.appendChild(cell);
        }
        tbody.appendChild(row);
    }

    if (curImgId != imgId) {
        // We're showing this popup for the first time, so try to
        // position it next to the image anchor.
        var el = document.getElementById(imgId);
        var p = getAbsolutePosition(el);

        layer.style.left = p.x + 'px';
        layer.style.top = p.y + 'px';
    }

    curImgId = imgId;
    layer.appendChild(table);

    layer.style.display = 'block';
    layer.style.visibility = 'visible';
}

function getAbsolutePosition(el)
{
    var r = {x: el.offsetLeft, y: el.offsetTop};
    if (el.offsetParent) {
        var tmp = getAbsolutePosition(el.offsetParent);
        r.x += tmp.x;
        r.y += tmp.y;
    }
    return r;
}

--- NEW FILE: open_colorpicker.js ---
function openColorPicker(target)
{
    var lay = document.getElementById('colorpicker_' + target);
    if (lay.style.display == 'block') {
        lay.style.display = 'none';
        return false;
    }

    if (lay.firstChild) {
        if (lay.firstChild.nodeType == 1) {
            lay.style.display = 'block';
            return false;
        }
        else {
            lay.removeChild(lay.firstChild);
        }
    }

    var table = document.createElement('table');
    var tbody = document.createElement('tbody');
    table.appendChild(tbody);
    table.cellSpacing = 0;
    table.border = 0;
    table.style.cursor = 'crosshair';
    table.onmouseout = function() {
        document.getElementById('colordemo_' + target).style.backgroundColor = document.getElementById(target).value;
        return false;
    }

    // The palette
    r = 0; g = 0; b = 0;
    for (b = 0; b < 6; b++) {
        row = document.createElement('tr');
        color = makeColor(b * 51, b * 51, b * 51);
        cell = makeCell(target, color);
        row.appendChild(cell);
        for (g = 0; g < 6; g++) {
            for (r = 0; r < 6; r++) {
                if (r != b && b != g) {
                    color = makeColor(r * 51, g * 51, b * 51);
                    cell = makeCell(target, color);
                    row.appendChild(cell);
                }
            }
        }
        tbody.appendChild(row);
    }

    table.appendChild(tbody);
    lay.appendChild(table);
    lay.style.display = 'block';
}

function makeCell(target, color)
{
    cell = document.createElement('td');
    cell.height = 3;
    cell.width = 6;
    cell.id = color;
    cell.style.backgroundColor = color;
    cell.onmouseover = function() {
        document.getElementById('colordemo_' + target).style.backgroundColor = this.style.backgroundColor;
        return false;
    }
    cell.onclick = function() {
        document.getElementById('colordemo_' + target).style.backgroundColor = this.style.backgroundColor;
        document.getElementById(target).value = this.id;
        return false;
    }

    return cell;
}

function makeColor(r, g, b)
{
    color = "#";
    color += hex(Math.floor(r / 16));
    color += hex(r % 16);
    color += hex(Math.floor(g / 16));
    color += hex(g % 16);
    color += hex(Math.floor(b / 16));
    color += hex(b % 16);
    return color;
}

function hex(Dec)
{
    if (Dec == 10) return "a";
    if (Dec == 11) return "b";
    if (Dec == 12) return "c";
    if (Dec == 13) return "d";
    if (Dec == 14) return "e";
    if (Dec == 15) return "f";
    return "" + Dec;
}

--- NEW FILE: open_google_win.js ---
<?php if (!strstr($_SERVER['PHP_SELF'], 'javascript.php')): ?><script language="JavaScript" type="text/javascript">
<!--
<?php endif; ?>
function open_google_win(args)
{
    var url = "";
    for (var i=0; i < document.google.area.length; i++)
    {
        if (document.google.area[i].checked)
        {
            var val = document.google.area[i].value;
        }
    }

    var $lang='<?php echo substr($GLOBALS["prefs"]->getValue("language"),0,2); ?>';

    switch (val) {
	case "web":
    	url = "http://www.google.com/search?ie=UTF-8&oe=UTF-8&hl=" + $lang + "&q=";
	    break;

	case "images":
	    url = "http://images.google.com/images?ie=UTF-8&oe=UTF-8&hl=" + $lang + "&q=";
            break;

	case "groups":
	    url = "http://groups.google.com/groups?ie=UTF-8&oe=UTF-8&hl=" + $lang + "&q=";
            break;

	case "directory":
	    url = "http://www.google.com/search?lr=&ie=UTF-8&oe=UTF-8&hl=" + $lang + "&cat=gwd%2FTop&q=";
            break;

	case "news":
	    url = "http://news.google.com/news?ie=UTF-8&oe=UTF-8&hl=" + $lang + "&q=";
            break;

	default:
    	url = "http://www.google.com/search?ie=UTF-8&oe=UTF-8&hl=" + $lang + "&q=";
    }

    var name = "Google";
    var param = "toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,width=800,height=600,left=0,top=0";
    url = url + escape(document.google.q.value);
    eval ("name = window.open(url, name, param)");
    if (!eval("name.opener")) eval("name.opener = self");
}

// -->
<?php if (!strstr($_SERVER['PHP_SELF'], 'javascript.php')): ?>// -->
</script>
<?php endif; ?>

--- NEW FILE: open_help_win.js ---
function open_help_win(module, topic)
{
    var win_location;
    var screen_width, screen_height;
    var win_top, win_left;
    var HelpWin;

    screen_height = 0;
    screen_width = 0;
    win_top = 0;
    win_left = 0;

    var help_win_width = 300;
    var help_win_height = 300;

    if (window.innerWidth) screen_width = window.innerWidth;
    if (window.innerHeight) screen_height = window.innerHeight;

    url = '<?php echo Horde::url($GLOBALS['registry']->getParam('webroot', 'horde') . '/services/help/', true) ?>';
    if (url.indexOf('?') == -1) {
        glue = '?';
    } else {
        glue = '<?php echo ini_get('arg_separator.output') ?>';
    }
    url += glue + 'module=' + module;
    glue = '<?php echo ini_get('arg_separator.output') ?>';
    if (topic != null) {
        if (topic == "") {
            url += glue + 'show=topics';
        } else {
            url += glue + 'topic=' + topic;
        }
    }

    win_top = screen_height - help_win_height - 20;
    win_left = screen_width - help_win_width - 20;
    HelpWin = window.open(url, 'HelpWindow',
        'resizable,width=' + help_win_width + ',height=' + help_win_height + ',top=' + win_top + ',left=' + win_left
    );
    HelpWin.focus();
}

--- NEW FILE: open_html_helper.js ---
/**
 * Horde Html Helper Javascript Class
 *
 * Provides the javascript class insert html tags by clicking on icons.
 *
 * The helpers available:
 *      emoticons - for inserting emoticons strings
 *
 * $Horde: horde/templates/javascript/open_html_helper.js,v 1.7 2004/04/07 14:43:48 chuck Exp $
 *
 * Copyright 2003-2004 Marko Djukic <marko at oblo.com>
 *
 * See the enclosed file COPYING for license information (GPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * @author Marko Djukic <marko at oblo.com>
 * @version $Revision: 1.1 $
 * @package horde
 * @todo add handling for font tags, tables, etc.
 */

var targetElement;

function openHtmlHelper(type, target)
{
    var lay = document.getElementById('htmlhelper_' + target);
    targetElement = document.getElementById(target);

    if (lay.style.visibility == 'visible') {
        lay.style.visibility = 'hidden';
        return false;
    }

    if (lay.firstChild) {
        lay.removeChild(lay.firstChild);
    }

    var table = document.createElement('TABLE');
    var tbody = document.createElement('TBODY');
    table.appendChild(tbody);
    table.cellSpacing = 0;
    table.border = 0;

    if (type == 'emoticons') {
        row = document.createElement('TR');
        cell = document.createElement('TD');
        <?php require_once 'Horde/Text/Filter/emoticons.php'; $patterns = Text_Filter_emoticons::getPatterns(); $icons = array_flip($patterns['replace']); foreach ($icons as $icon => $string): ?>
        link = document.createElement('A');
        link.href = '#';
        link.onclick = function() {
            targetElement.value = targetElement.value + '<?php echo $string; ?>' + ' ';
        }
        cell.appendChild(link);
        img = document.createElement('IMG')
        img.src = '<?php echo $GLOBALS['registry']->getParam('graphics', 'horde') . '/emoticons/' . $icon . '.gif'; ?>';
        img.align = 'middle';
        img.border = 0;
        link.appendChild(img);
        <?php endforeach; ?>
        row.appendChild(cell);
        tbody.appendChild(row);
        table.appendChild(tbody);
    }

    lay.appendChild(table);
    lay.style.visibility = 'visible';
}

--- NEW FILE: open_print_win.js ---
<script language="JavaScript" type="text/javascript">
<!--

function open_print_win(url)
{
    var now = new Date();
    var name = "print_window_" + now.getTime();
    param = "toolbar=yes,location=no,status=yes,scrollbars=yes,resizable=yes,width=630,height=460,left=0,top=0";
    eval ("name = window.open(url, name, param)");
    if (!eval("name.opener")) eval("name.opener = self");
}

// -->
</script>

--- NEW FILE: open_share_edit_win.js ---
function open_share_edit_win(url)
{
    var now = new Date();
    var name = "share_edit_window_" + now.getTime();
    param = "toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=600,height=500,left=0,top=0";
    eval("name = window.open(url, name, param)");
    if (!eval("name.opener")) {
        eval("name.opener = self");
    }
}

--- NEW FILE: popup.js ---
function popup(url, width, height)
{
    if (!width) {
        width = 600;
    }
    if (!height) {
        height = 500;
    }

    var now = new Date();
    var name = now.getTime();
    param = "toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",left=0,top=0";
    eval("name = window.open(url, name, param)");
    if (!eval("name.opener")) {
        eval("name.opener = self");
    }

    return name;
}

--- NEW FILE: print.js ---
<script language="JavaScript" type="text/javascript">
<!--

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1);

function printWin()
{
    if (pr) {
        // NS4+, IE5+
        window.print();
    } else if (!mac) {
        // IE3 and IE4 on PC
        VBprintWin();
    } else {
        // everything else
        handle_error();
    }
}

window.onerror = handle_error;
window.onafterprint = function() {window.close()}

function handle_error()
{
    window.alert('<?php echo addslashes(_("Your browser does not support this print option. Press Control/Option + P to print.")) ?>');
    return true;
}

if (!pr && !mac) {
    if (da) {
        // This must be IE4 or greater
        wbvers = "8856F961-340A-11D0-A96B-00C04FD705A2";
    } else {
        // this must be IE3.x
        wbvers = "EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B";
    }

    document.write("<OBJECT ID=\"WB\" WIDTH=\"0\" HEIGHT=\"0\" CLASSID=\"CLSID:");
    document.write(wbvers + "\"> </OBJECT>");
}

// -->
</script>

<script language="VBSCript" type="text/vbscript">
<!--

sub window_onunload
    on error resume next
    ' Just tidy up when we leave to be sure we aren't
    ' keeping instances of the browser control in memory
    set WB = nothing
end sub

sub VBprintWin
    OLECMDID_PRINT = 6
    on error resume next

    ' IE4 object has a different command structure
    if da then
        call WB.ExecWB(OLECMDID_PRINT, 1)
    else
        call WB.IOleCommandTarget.Exec(OLECMDID_PRINT, 1, "", "")
    end if
end sub

' -->
</script>

<script language="JavaScript" type="text/javascript">
<!--
printWin();
// -->
</script>

--- NEW FILE: sorter.js ---
/**
 * Horde Form Sorter Field Javascript Class
 *
 * Provides the javascript class to accompany the Horde_Form sorter
 * field.
 *
 * $Horde: horde/templates/javascript/sorter.js,v 1.2 2004/01/01 16:17:43 jan Exp $
 *
 * Copyright 2003-2004 Marko Djukic <marko at oblo.com>
 *
 * See the enclosed file COPYING for license information (GPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * @author Marko Djukic <marko at oblo.com>
 * @version $Revision: 1.1 $
 * @package horde
 */

function Horde_Form_Sorter(instanceName, varName, header)
{
    /* Set up this class instance for function calls from the page. */
    this._instanceName = instanceName;

    this._varName = varName;

    /* Sorter variables. */
    this._header = '';
    this.minLength = 0;
    if (header != '') {
        this._header = header;
        this.minLength = 1;
    }
    this.sorterList = document.getElementById(this._varName + '[list]');
    this.sorterArray = document.getElementById(this._varName + '[array]');

    this.deselectHeader = function()
    {
        if (this._header != '') {
            this.sorterList[0].selected = false;
        }
    }

    this.setHidden = function()
    {
        var tmpArray = new Array();

        for (var i = this.minLength; i < this.sorterList.length; i++) {
            if (this.sorterList[i].value) {
                tmpArray[i - this.minLength] = this.sorterList[i].value;
            }
        }

        this.sorterArray.value = tmpArray.join("\t");
    }

    this.moveColumnUp = function()
    {
        var sel = this.sorterList.selectedIndex;

        if (sel <= this.minLength || this.sorterList.length <= this.minLength + 1) return;

        /* Deselect everything but the first selected item. */
        this.sorterList.selectedIndex = sel;
        var up = this.sorterList[sel].value;

        tmp = new Array();
        for (i = this.minLength; i < this.sorterList.length; i++) {
            tmp[i - this.minLength] = new Option(this.sorterList[i].text, this.sorterList[i].value)
        }

        for (i = 0; i < tmp.length; i++) {
            if (i + this.minLength == sel - 1) {
                this.sorterList[i + this.minLength] = tmp[i + 1];
            } else if (i + this.minLength == sel) {
                this.sorterList[i + this.minLength] = tmp[i - 1];
            } else {
                this.sorterList[i + this.minLength] = tmp[i];
            }
        }

        this.sorterList.selectedIndex = sel - 1;

        this.setHidden();
    }

    this.moveColumnDown = function()
    {
        var sel = this.sorterList.selectedIndex;

        if (sel == -1 || this.sorterList.length <= 2 || sel == this.sorterList.length - 1) return;

        /* Deselect everything but the first selected item. */
        this.sorterList.selectedIndex = sel;
        var down = this.sorterList[sel].value;

        tmp = new Array();
        for (i = this.minLength; i < this.sorterList.length; i++) {
            tmp[i - this.minLength] = new Option(this.sorterList[i].text, this.sorterList[i].value)
        }

        for (i = 0; i < tmp.length; i++) {
            if (i + this.minLength == sel) {
                this.sorterList[i + this.minLength] = tmp[i + 1];
            } else if (i + this.minLength == sel + 1) {
                this.sorterList[i + this.minLength] = tmp[i - 1];
            } else {
                this.sorterList[i + this.minLength] = tmp[i];
            }
        }

        this.sorterList.selectedIndex = sel + 1;

        this.setHidden();
    }
}

--- NEW FILE: tooltip.js ---
var isIE = document.all ? true : false;
var activeTimeout;

if (!isIE) {
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = mousePos;
    var netX, netY;
}

function posX() {
    if (isIE) {
      tempX = document.body.scrollLeft + event.clientX;
    }
    if (tempX < 0) {
      tempX = 0;
    }
    return tempX;
}

function posY() {
    if (isIE) {
      tempY = document.body.scrollTop + event.clientY;
    }
    if (tempY < 0) {
     tempY = 0;
    }
    return tempY;
}

function mousePos(e) {
    netX = e.pageX;
    netY = e.pageY;
}

function tooltipShow(pX, pY, src) {
    if (pX < 1) {
        pX = 1;
    }
    if (pY < 1) {
        pY = 1;
    }
    if (isIE) {
        document.all.tooltip.style.visibility = 'visible';
        document.all.tooltip.innerHTML = src;
        document.all.tooltip.style.left = pX + 'px';
        document.all.tooltip.style.top = pY + 'px';
    } else {
        document.getElementById('tooltip').style.visibility = 'visible';
        document.getElementById('tooltip').style.left = pX + 'px';
        document.getElementById('tooltip').style.top = pY + 'px';
        document.getElementById('tooltip').innerHTML = src;
    }
}

function tooltipClose() {
    if (isIE) {
        document.all.tooltip.innerHTML = '';
        document.all.tooltip.style.visibility = 'hidden';
    } else {
        document.getElementById('tooltip').style.visibility = 'hidden';
        document.getElementById('tooltip').innerHTML = '';
    }
    clearTimeout(activeTimeout);
    window.status = '';
}

function tooltipLink(tooltext, statusline) {
    text = '<table cellspacing="0" cellpadding="4" border="0">';
    text += '<tr><td class="tooltip">' + tooltext + '</td></tr></table>';
    if (isIE) {
        xpos = posX();
        ypos = posY();
    } else {
        xpos = netX;
        ypos = netY;
    }
    activeTimeout = setTimeout('tooltipShow(xpos - 110, ypos + 15, text);', 300);
    window.status = statusline;
}

document.write('<div id="tooltip" style="position: absolute; visibility: hidden;"></div>');

--- NEW FILE: tree.js ---
/**
 * Horde Tree Javascript Class
 *
 * Provides the javascript class to create dynamic trees.
 *
 * Copyright 2003-2004 Marko Djukic <marko at oblo.com>
 *
 * See the enclosed file COPYING for license information (GPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * $Horde: horde/templates/javascript/tree.js,v 1.23 2004/05/03 16:04:41 jan Exp $
 *
 * @author  Marko Djukic <marko at oblo.com>
 * @version $Revision: 1.1 $
 * @package Horde_Tree
 * @since   Horde 3.0
 */
function Horde_Tree(instanceName)
{
    /* Set up this class instance for function calls from the page. */
    this._instanceName = instanceName;

    /* Image variables. */
    this.imgDir         = '<?php echo $GLOBALS['registry']->getParam('graphics', 'horde') . '/tree'; ?>';
    this.imgLine        = 'line.gif';
    this.imgBlank       = 'blank.gif';
    this.imgJoin        = 'join.gif';
    this.imgJoinBottom  = 'joinbottom.gif';
    this.imgPlus        = 'plus.gif';
    this.imgPlusBottom  = 'plusbottom.gif';
    this.imgPlusOnly    = 'plusonly.gif';
    this.imgMinus       = 'minus.gif';
    this.imgMinusBottom = 'minusbottom.gif';
    this.imgMinusOnly   = 'minusonly.gif';
    this.imgFolder      = 'folder.gif';
    this.imgFolderOpen  = 'folderopen.gif';
    this.imgLeaf        = 'leaf.gif';

    /* Tree building variables. */
    this.rootNodeId     = '';
    this.target         = '';
    this.nodes          = new Array();
    this.node_pos       = new Array();
    this.dropline       = new Array();
    this.output         = '';
    this.altCount       = 0;
}

Horde_Tree.prototype.setTableStart = function(tableParams)
{
    this.tableStart = '<table' + tableParams + '>';
}

Horde_Tree.prototype.setImgDir = function(imgDir)
{
    this.imgDir = imgDir;
}

Horde_Tree.prototype.renderTree = function(rootNodeId)
{
    this.rootNodeId = rootNodeId;
    this.nodes = eval('n_' + this._instanceName);
    this.options = eval('o_' + this._instanceName);
    this.target = 't_' + this._instanceName;
    this._renderTree();
}

Horde_Tree.prototype._renderTree = function()
{
    this.output = '';
    this.buildTree(this.rootNodeId);
    document.getElementById(this.target).innerHTML = this.tableStart + this.output + '</table>';
    this.altCount = 0;
}

/*
 * Recursive function to walk through the tree array and build
 * the output.
 */
Horde_Tree.prototype.buildTree = function(nodeId)
{
    this.output += this.buildLine(nodeId);

    if (typeof(this.nodes[nodeId]['children']) != 'undefined' &&
        this.nodes[nodeId]['expanded']) {
        var numSubnodes = this.nodes[nodeId]['children'].length;
        for (var c = 0; c < numSubnodes; c++) {
            var childNodeId = this.nodes[nodeId]['children'][c];
            this.node_pos[childNodeId] = new Array();
            this.node_pos[childNodeId]['pos'] = c + 1;
            this.node_pos[childNodeId]['count'] = numSubnodes;
            this.buildTree(childNodeId);
        }
    }

    return true;
}

Horde_Tree.prototype.buildLine = function(nodeId)
{
    var nodeClass = '';
    if (this.options['alternate']) {
        this.altCount = (this.altCount ? 0 : 1);
    }

    if (this.nodes[nodeId]['class']) {
        nodeClass = ' class="' + this.nodes[nodeId]['class'] + '"';
    } else if (this.options['class']) {
        nodeClass = ' class="' + this.options['class'] + this.altCount + '"';
    } else {
        nodeClass = ' class="item' + this.altCount + '"';
    }

    var line = '<tr>';

    if (typeof(this.nodes[nodeId]['extra']) != 'undefined' &&
        typeof(this.nodes[nodeId]['extra'][0]) != 'undefined') {
        var extra = this.nodes[nodeId]['extra'][0];
        for (var c = 0; c < extra.length; c++) {
            line += '<td' + nodeClass + ' align="center">' + extra[c] + '</td>';
        }
        for (var d = c; d < extraColsLeft; d++) {
            line += '<td' + nodeClass + '> </td>';
        }
    } else {
        for (var c = 0; c < extraColsLeft; c++) {
            line += '<td' + nodeClass + '> </td>';
        }
    }

    line += '<td' + nodeClass + '>';

    for (var i = 0; i < this.nodes[nodeId]['indent']; i++) {
        if (this.dropline[i]) {
            line += '<img src="' + this.imgDir + '/' + this.imgLine + '" height="20" width="20" align="middle" border="0" />';
        } else {
            line += '<img src="' + this.imgDir + '/' + this.imgBlank + '" height="20" width="20" align="middle" border="0" />';
        }
    }

    line += this._setNodeToggle(nodeId) + this._setNodeIcon(nodeId) + this._setLabel(nodeId) + '</td>';

    if (typeof(this.nodes[nodeId]['extra']) != 'undefined' &&
        typeof(this.nodes[nodeId]['extra'][1]) != 'undefined') {
        var extra = this.nodes[nodeId]['extra'][1];
        for (var c = 0; c < extra.length; c++) {
            line += '<td' + nodeClass + ' align="center">' + extra[c] + '</td>';
        }
        for (var d = c; d < extraColsRight; d++) {
            line += '<td' + nodeClass + '> </td>';
        }
    } else {
        for (var c = 0; c < extraColsRight; c++) {
            line += '<td' + nodeClass + '> </td>';
        }
    }
    line += '</tr>';

    return line;
}

Horde_Tree.prototype._setLabel = function(nodeId)
{
    var label = this.nodes[nodeId]['label'];
    var onClick = '';
    if (this.nodes[nodeId]['onclick']) {
        onClick = ' onclick="' + this.nodes[nodeId]['onclick'] + '" style="cursor:pointer"';
    }
    if (this.nodes[nodeId]['url']) {
        label = '<a href="' + this.nodes[nodeId]['url'] + '">' + label + '</a>';
    }
    return '<span' + onClick + '>' + label + '</span></td>';
}

Horde_Tree.prototype._setNodeToggle = function(nodeId)
{
    var attrib = '';
    if (nodeId == this.rootNodeId &&
        typeof(this.nodes[nodeId]['children']) != 'undefined') {
        /* Root, and children. */
        img = (this.nodes[nodeId]['expanded']) ? this.imgMinusOnly : this.imgPlusOnly;
        this.dropline[0] = false;
        attrib = ' style="cursor:pointer;cursor:hand;" onclick="' + this._instanceName + '.toggle(\'' + nodeId + '\')"';
    } else if (nodeId != this.rootNodeId &&
        typeof(this.nodes[nodeId]['children']) == 'undefined') {
        /* Node no children. */
        if (this.node_pos[nodeId]['pos'] < this.node_pos[nodeId]['count']) {
            /* Not last node. */
            img = this.imgJoin;
            this.dropline[this.nodes[nodeId]['indent']] = true;
        } else {
            /* Last node. */
            img = this.imgJoinBottom;
            this.dropline[this.nodes[nodeId]['indent']] = false;
        }
    } else if (typeof(this.nodes[nodeId]['children']) != 'undefined') {
        /* Node with children. */
        if (this.node_pos[nodeId]['pos'] < this.node_pos[nodeId]['count']) {
            /* Not last node. */
            img = (this.nodes[nodeId]['expanded']) ? this.imgMinus : this.imgPlus;
            this.dropline[this.nodes[nodeId]['indent']] = true;
        } else {
            /* Last node. */
            img = (this.nodes[nodeId]['expanded']) ? this.imgMinusBottom : this.imgPlusBottom;
            this.dropline[this.nodes[nodeId]['indent']] = false;
        }
        attrib = ' style="cursor:pointer;cursor:hand;" onclick="' + this._instanceName + '.toggle(\'' + nodeId + '\')"';
    } else {
        /* Root only, no children. */
        img = this.imgMinusOnly;
        this.dropline[0] = false;
    }

    return '<img src="' + this.imgDir + '/' + img + '" ' + attrib + ' height="20" width="20" align="middle" border="0" />';
}

Horde_Tree.prototype._setNodeIcon = function(nodeId)
{
    var imgDir = (this.nodes[nodeId]['icondir']) ? this.nodes[nodeId]['icondir']
                                                 : this.imgDir;
    if (typeof(this.nodes[nodeId]['icon']) != 'undefined') {
        /* Node has a user defined icon. */
        if (typeof(this.nodes[nodeId]['iconopen']) != 'undefined' && this.nodes[nodeId]['expanded']) {
            img = this.nodes[nodeId]['iconopen'];
        } else {
            img = this.nodes[nodeId]['icon'];
        }
    } else {
        /* Use standard icon set. */
        if (typeof(this.nodes[nodeId]['children']) != 'undefined') {
            /* Node with children. */
            img = (this.nodes[nodeId]['expanded']) ? this.imgFolderOpen
                                                   : this.imgFolder;
        } else {
            /* Node no children. */
            img = this.imgLeaf;
        }
    }

    var imgtxt = '<img src="' + imgDir + '/' + img + '" align="middle" border="0" ';

    if (typeof(this.nodes[nodeId]['iconalt']) != 'undefined') {
        imgtxt += 'alt="' + this.nodes[nodeId]['iconalt'] + '" ';
    }

    return imgtxt + '/>';
}

Horde_Tree.prototype.toggle = function(nodeId)
{
    this.nodes[nodeId]['expanded'] = !this.nodes[nodeId]['expanded'];
    this.saveState(nodeId, this.nodes[nodeId]['expanded'])
    this._renderTree();
}

Horde_Tree.prototype.saveState = function(nodeId, expanded)
{
    var newCookie = '';
    var oldCookie = this._getCookie(this._instanceName + '_expanded');
    if (expanded) {
        /* Expand requested so add to cookie. */
        newCookie = (oldCookie) ? oldCookie + ',' : '';
        newCookie = newCookie + nodeId;
    } else {
        /* Collapse requested so remove from cookie. */
        var nodes = oldCookie.split(',');
        var newNodes = new Array();
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i] != nodeId) {
                newNodes.push(nodes[i]);
            }
        }
        newCookie = newNodes.join(',');
    }
    this._setCookie(this._instanceName + '_expanded', newCookie);
}

Horde_Tree.prototype._getCookie = function(name)
{
    var dc = document.cookie;
    var prefix = name + '=';
    var begin = dc.indexOf('; ' + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) {
            return '';
        }
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

Horde_Tree.prototype._setCookie = function(name, value)
{
    var curCookie = name + '=' + escape(value);
    curCookie = curCookie + ';DOMAIN=<?php echo $GLOBALS['conf']['cookie']['domain']; ?>;PATH=<?php echo $GLOBALS['conf']['cookie']['path']; ?>;';
    document.cookie = curCookie;
}





More information about the commits mailing list