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

var last_compose_win;

function open_compose_win(args)
{
    var url = "<?php echo Horde::url($GLOBALS['registry']->applicationWebPath('%application%/compose.php', 'imp')) ?>";
    if (url.indexOf('?') == -1) {
        var glue = '?';
    } else {
        var glue = '&';
    }
    var now = new Date();
    var name = "compose_windows_" + now.getTime();
    if (args != "") {
        url = url + glue + args + "&uniq=" + now.getTime();
    } else {
        url = url + glue + "uniq=" + now.getTime();
    }
    var width = screen.width;
    if (width > 775) {
        width = 700;
    } else {
        width -= 75;
    }
    var height = screen.height;
    if (height > 725) {
        height = 650;
    } else {
        height -= 75;
    }
    param = "toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",left=0,top=0";
    name = window.open(url, name, param);
    if (!name) {
        alert("<?php echo addslashes(_("The compose window can't be opened. Perhaps you have set your browser to block popup windows?")) ?>");
    } else {
        if (!eval("name.opener")) {
            name.opener = self;
        }

        last_compose_win = name;
    }
}

function focus_compose_win(compose_win)
{
    if (!compose_win) {
        compose_win = last_compose_win;
    }

    if (!compose_win) {
        return;
    }

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