
    function kickUser(e, redir, do_deactivate)
    {
        if (getRecordId()) {
            var deactivate = false;
            if(do_deactivate) {
                if(confirm('Are you sure you wish to Kick and Deactivate this User?')) {
                    document.location = package_root + '/kick_user.php?user_id=' + getRecordId() + '&deactivate=1' + redir;
                }
            } else {
                if(confirm('Are you sure you wish to Kick this User from the system?')) {
                    document.location = package_root + '/kick_user.php?user_id=' + getRecordId() + redir;
                }
            }

        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function sendMessage(e, redir)
    {
        if (getRecordId()) {
            var owin = openWindow(e,'message.php?id=' + getRecordId(), 300, 300);
            owin.focus();
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an User');
        }
    }

    function onDeleteAccount(e, redir)
    {
        if (getRecordId()) {
            delayedConfirm(e, 3, 'Are you certain you wish to delete the selected Account?', package_root + '/account/del.php?id=' + getRecordId() + '&r=' + encodeURIComponent(document.location), 0, 0, '');
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function logIntoAccountUser(e, redir)
    {
        if (getRecordId()) {
            // :NOTE: do not use package_root as the account users package also calls this function
            document.location = '/admin/account/login.php?user_id=' + getRecordId() + redir;
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select a User');
        }
    }

    function batchAccountLogin(e, redir)
    {
        if (getRecordId()) {
            document.location = package_root +'/usage/batch_account_login.php?id=' + getRecordId() + redir;
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }


    function editAccountUser(e, redir)
    {
        if (getRecordId()) {
            document.location = package_root + '/account/mod.php?user_id=' + getRecordId() + redir;
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account to edit');
        }
    }

    function viewDailies(e, date_val)
    {
        if (getRecordId()) {
            document.location = 'usage_dailies.php?id=' + date_val + '&account_id=' + getRecordId() + '&r=' + escape(location.href);
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function viewUsageTrends(e)
    {
        if (getRecordId()) {
            var owin = openWindow(e,package_root + '/usage/usage_detail.php?id=' + getRecordId(), 700, (ns)?510:500);
            owin.focus();
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function viewSubUsage(e, month, year)
    {
        if (getRecordId()) {
            document.location = package_root + '/usage/usage.php?pid=' + getRecordId() +'&month='+month+'&year='+year;
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function viewSubAccounts(e)
    {
        if (getRecordId()) {
            document.location = package_root + '/account/index.php?pid=' + getRecordId();
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    var sub_account_changed = false;
    function subAccountChanged() {
        sub_account_changed = true;
    }
    function checkSubAccountMode(selector, checkbox) {
        if (!sub_account_changed) {
            if (selector.options[selector.selectedIndex].value == 'account_id') {
                checkbox.checked = true;
            } else {
                checkbox.checked = false;
            }
        }
    }

    function logIntoAccount(e, redir)
    {
        if (getRecordId()) {
            document.location = package_root + '/account/login.php?acc_id=' + getRecordId() + redir;
        } else {
             customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function editAccount(e)
    {
        if (getRecordId()) {
            document.location = package_root + '/account/mod.php?id=' + getRecordId();
        } else {
             customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function viewParentUsage(parent_id) {
        document.location = 'usage.php?id=' + parent_id;
    }

    function approveAccount(e) {
        if(getRecordId()){
            if (confirm('Approving this account will:\n\n    1. Change Account type to "Standard"\n    2. Remove any send restrictions\n    3. Remove any Expiry date\n\nThese settings may be changed at a later date.\nAre you sure?')) {
                location.href = 'trial_approve.php?id=' + getRecordId();
            }
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function deleteAccount(e, delete_url) {
        if(getRecordId()){
            var width = 350;
            var height = 140;
            var message = '<p>Are you sure you want to delete this Trial Account?</p>';
            var url = delete_url + '?id='+getRecordId()+'&r='+escape(document.location.href);
            delayedConfirm(e, 5, message, url, undefined, undefined, undefined, undefined, false, true, width, height);
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select a Trial Account to Delete.');
        }
    }

    function contactDetails(e, user_id, db_id) {
        if (user_id && db_id) {
            openWindow(e, '/' + getPackageAlias('em') + '/users/user_details/index.php?uid=' + user_id + '&db_id=' + db_id + '&uo=0', 800, 600);
        }
    }

    function contactAccountDetails(e, account_id) {

        if (!account_id) {
            account_id = getRecordId();
        }

        if (account_id) {
            var new_width = 800;
            if (screen.width >= document.body.scrollWidth) {
                new_width = Math.min(document.body.scrollWidth + 20, screen.width - 20);
            }
            var w = openWindow(e, '/' + getPackageAlias('em') + '/users/user_details/index.php?account_id=' + account_id, new_width, 600, 'resizable=1, scrollbars=yes');
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function editCustomTabMenus(e) {
        if(getRecordId()) {
            location.href = 'menus.php?id=' + getRecordId();
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select a Custom Tab');
        }
    }

    function editCustomTabMenuItems(e) {
        if(getRecordId()) {
            location.href = 'menu_items.php?id=' + getRecordId();
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select a Menu');
        }
    }


    function toggleCustomTab(e) {
        if(getRecordId()) {
            location.href = 'toggle.php?id=' + getRecordId();
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select a Custom Tab');
        }
    }


    function viewAccountCustomTabs(e) {
        account_id = getRecordId();
        if (account_id) {
            openWindow(e, package_root + '/tabs/account_tabs.php?id=' + account_id, 400, 300, 'resizable=1, scrollbars=yes');
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Account');
        }
    }

    function modifyUnconfirmedTrialRequest(e) {
        trial_request_id = getRecordId();
        if (trial_request_id) {
            location.href = 'mod.php?id=' + escape(trial_request_id);
        } else {
            customInfoBubble(getObjectFromEvent(e), 'Please select an Unconfirmed Trial Account');
        }
    }


     function updateBrandingField(e) {
        if(confirm("WARNING:\r\n\r\nIn some cases, Branding and Virtual Host changes cannot be un-done.\r\n\r\nAre you sure you want to continue?")) {
            return true;
        } else {
            obj = getObjectFromEvent(e);
            obj.selectedIndex = 0;
            return false;
        }
     }

