avatar_control.naml

<macro name="avatar_control" parameters="group">
    <n.put_in_head.>
        <style type="text/css">
            span.avatar-show,
            span.avatar-hide {
                float:left;
                cursor:pointer;
                margin: 0 .2em;
            }
            span.avatar-hide { display:none; }
        </style>
        <script type="text/javascript">
            function checkAvatar(group) {
                var value = Nabble.getCookie('avatar'+group);
                if (value == 't' || !value) {
                    $(document).ready(function() {
                        $('#avatar'+group+'-show').hide();
                        $('#avatar'+group+'-hide').show();
                    });
                    return true;
                }
                return false;
            };

            $(document).ready(function() {
                function hideAvatar(group) {
                    $("#avatar" + group + "-hide").hide();
                    $("span.avatar" + group).hide();
                    $("#avatar" + group + "-show").show();
                    Nabble.setPersistentCookie('avatar'+group, 'f');
                    Nabble.resizeFrames();
                };

                function showAvatar(group) {
                    Nabble.setPersistentCookie('avatar'+group, 't');
                    if ($.browser.opera || navigator.appVersion.indexOf("MSIE 6") != -1) {
                        window.location.reload();
                        return;
                    }
                    $("#avatar" + group + "-show").hide();
                    $("span.avatar" + group + " img").each(function() {
                        var xsrc = $(this).attr('xsrc');
                        $(this).attr('src', xsrc);
                    });
                    $("span.avatar" + group).fadeIn();
                    $("#avatar" + group + "-hide").show();
                    Nabble.resizeFrames();
                };

                $("span.avatar-hide").click(function() {
                    var group = $(this).attr('group');
                    hideAvatar(group);
                });

                $("span.avatar-show").click(function() {
                    var group = $(this).attr('group');
                    showAvatar(group);
                });
            });
        </script>
    </n.put_in_head.>

    <script type="text/javascript">
        window.hasAvatar<n.group/> = checkAvatar('<n.group/>');
        if (!window.hasAvatar<n.group/>)
            document.write('<n.javascript_string_encode.><style type="text/css">span.avatar<n.group/> { display:none; } </style></n.javascript_string_encode.>');
    </script>
    <span id="avatar[n.group/]-hide" class="avatar-hide" group="[n.group/]" title="Click to hide avatars">
        <img src="/images/avatar_no.png" align="absmiddle" width="18" height="18" style="vertical-align:bottom"/>
    </span>
    <span id="avatar[n.group/]-show" class="avatar-show" group="[n.group/]" title="Click to show avatars">
        <img src="/images/avatar_yes.png" align="absmiddle" width="18" height="18" style="vertical-align:bottom"/>
    </span>
</macro>