(function(win, doc) {
    var uid = "",
    isLogin = '';
    if (win.J) {
        isLogin = +J.isLogin;
    }
    if (win.J16_INF) {
        uid = J16_INF.uid;
    }
    var bind = win.attachEvent ?
    function(dom, eventType, handler) {
        dom.attachEvent('on' + eventType, handler)
    }: function(dom, eventType, handler) {
        dom.addEventListener(eventType, handler, false)
    };
    var euc = encodeURIComponent;
    var stat = (new
    function() {
        this.createImg = function(src) {
            var img = doc.createElement('IMG');
            img.src = src;
        };
        this.s16 = function(a, p) {
            var wp = ["act=" + a, "log=" + isLogin, "uid=" + uid];
            for (var i = 0; i < p.length; i += 2) {
                wp.push(p[i] + "=" + euc(p[i + 1]));
            }
            this.createImg("http://st.1616.net/s.php?" + wp.join("&"));
        };
        this.init = function(wrap) {
            var T = this;
            bind(wrap, 'mousedown',
            function(e) {
                var e = e.target || win.event.srcElement;
                var getPn = function(dom) {
                    var attr = dom.getAttribute('s16');
                    if (attr === null && dom.parentNode && dom.parentNode != (wrap.body || wrap)) {
                        return getPn(dom.parentNode);
                    } else {
                        var ret = {},
                        a, attr = attr.split(',');
                        while (a = attr.pop()) {
                            a = a.split('=') if (a.length == 2) ret[a[0]] = a[1]
                        }
                    }
                    return ret
                };
                var atr = e.getAttribute && e.getAttribute('s16');
                if (atr && atr.match(/^#/)) {
                    return T.createImg("http://st.1616.net/s.php?" + atr.replace('#', ''));
                }
                if (e.tagName == 'FONT' || e.tagName == 'IMG') e = e.parentNode;
                if (e.tagName == 'A') {
                    var p = getPn(e);
                    if (p !== null) {
                        T.s16(p.act, ['pn', p.pn, 'u', e.href, 't', (e.textContent || e.innerText).replace(/ /g, '')]);
                    }
                }
            });
            return this;
        };
    }).init(doc);
})(window, window.document);