var FF = window.FF || {};
FF.namespace = function() {
    var a = arguments,
    o = null,
    i, j, d;
    for (i = 0; i < a.length; ++i) {
        d = a[i].split(".");
        o = FF;
        for (j = (d[0] == "FF") ? 1 : 0; j < d.length; ++j) {
            o[d[j]] = o[d[j]] || {};
            o = o[d[j]];
        }
    }
    return o;
};
FF.namespace("util", "app"); (function() {
    var $C = YAHOO.util.Connect;
    var $D = YAHOO.util.Dom;
    var $E = YAHOO.util.Event;
    var _9 = YAHOO.util.KeyListener;
    var _a = YAHOO.env.ua.ie;
    var _b = (_a == 6);
    var _c = YAHOO.env.ua.gecko;
    var _d = YAHOO.env.ua.webkit;
    var _e = YAHOO.env.ua.opera;
    var _f = YAHOO.lang.isString;
    
    FF.util = {
        breakWord: function(el) {
            el = $D.get(el);
            if (!el || el.nodeType !== 1) {
                return false;
            }
            if (el.currentStyle && typeof el.currentStyle.wordBreak === "string") {
                el.runtimeStyle.wordBreak = "break-all";
                return true;
            } else {
                if (document.createTreeWalker) {
                    var _14 = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false);
                    var _15, s, c = String.fromCharCode("8203");
                    while (_14.nextNode()) {
                        _15 = _14.currentNode;
                        s = trim(_15.nodeValue).split("").join(c);
                        _15.nodeValue = s;
                    }
                    return true;
                } else {
                    return false;
                }
            }
        },
        fixTextareaCursorPosition: function(_18) {
            if (_f(_18)) {
                _18 = $D.get(_18);
            }
            if (_a || _e) {
                var rng = _18.createTextRange();
                rng.text = _18.value;
                rng.collapse(false);
            } else {
                if (_d) {
                    _18.select();
                    window.getSelection().collapseToEnd();
                }
            }
        },
        
 
        Effect: {
            _yfade: function(el, _38, _39, _3a) {
                var a = arguments,
                f = "#fff478",
                t = "#ffffff";
                if (YAHOO.lang.isArray(a[2])) {
                    f = a[2][0] ? a[2][0] : f;
                    t = a[2][1] ? a[2][1] : t;
                } else {
                    if (YAHOO.lang.isFunction(a[2])) {
                        var cb = a[2];
                    }
                }
                if (YAHOO.lang.isFunction(a[3])) {
                    var cb = a[3];
                }
                var opa = _38 == "out" ? {
                    from: 1,
                    to: 0
                }: {
                    from: 0,
                    to: 1
                };
                var _40 = new YAHOO.util.ColorAnim(el, {
                    backgroundColor: {
                        from: f,
                        to: t
                    },
                    opacity: opa
                },
                1, YAHOO.util.Easing.easeNone);
                if ("undefined" != typeof cb) {
                    _40.onComplete.subscribe(function() {
                        cb(el);
                    });
                }
                _40.animate();
                return _40;
            },
            yellowFadeOut: function(el, _42, _43) {
                return FF.util.Effect._yfade(el, "out", _42, _43);
            },
            yellowFadeIn: function(el, _45, _46) {
                return FF.util.Effect._yfade(el, "in", _45, _46);
            }
        }
    };
    FF.widget = {
        selectAndCopy: function(_47, _48, _49) {
            if (_f(_47)) {
                _47 = $D.get(_47);
            }
            var _4a = "flashcopier",
            _4b = "flashembed";
            function copy(_4c) {
                if (!$D.get(_4a)) {
                    var _4d = document.createElement("div");
                    _4d.id = _4a;
                    document.body.appendChild(_4d);
                }
                var _4e = $D.get(_4a);
                _4e.innerHTML = "";
                var _4f = window[_4b] || document[_4b] || {};
                if (!_4f.SetVariable) {
                    try {
                        return window.clipboardData.setData("Text", _4c.value);
                    } catch(exx) {
                        return false;
                    }
                }
                return true;
            }
            $E.on(_47, "click", doCopy);
            $E.on(_48, "click", doCopy);
            function doCopy() {
                if (copy(_47) && _a) {
                    alert(_49 || "\u590d\u5236\u6210\u529f\uff0c\u4f60\u53ef\u4ee5\u7c98\u5e16\u5230MSN\u6216QQ\u4e2d\u53d1\u7ed9\u597d\u53cb\u3002");
                }
                setTimeout(function() {
                    _47.select();
                },
                0);
            }
        }
    };
    FF.app.QuickReply = function() {
        var _50 = $D.get("message");
        var _51 = _50["content"];
        var _52 = _50["in_reply_to_status_id"];
        var _53 = $D.get("stream");
        focus();
        $E.on(_53, "click",
        function(e) {
            var _55 = $E.getTarget(e);
            var _56 = _55.nodeName.toLowerCase();
            if (_56 == "a" && $D.hasClass(_55, "reply")) {
                $E.stopEvent(e);
                var _57 = _55.getAttribute("ffname");
                var id = _55.getAttribute("ffid");
                _51.value = combine("@" + _57, trim(_51.value));
                _52.value = id;
                window.scrollTo(0, 0);
                window.setTimeout(function() {
                    focus();
                },
                10);
            }
        });
        function combine(_59, _5a) {
            var _5b = " ";
            var _5c = _5a.split(_5b);
            if (_5a.length == 0) {
                return _59 + _5b;
            }
            for (var i = 0,
            len = _5c.length; i < len; i++) {
                if (_5c[i] == _59) {
                    _5c.splice(i, 1);
                    break;
                }
            }
            _5c.unshift(_59);
            return _5c.join(_5b) + _5b;
        }
        function focus() {
            _51.focus();
            FF.util.fixTextareaCursorPosition(_51);
        }
    };
    
    FF.app.Stream = {
        remove: function(el, _63, _64) {
            el.blur();
            if (_64 && !confirm(_64)) {
                return;
            }
            _63["ajax"] = "yes";
            var _65 = el.getAttribute("redirect");
            var _66 = FF.util.toPostData(_63);
            var _67 = $C.asyncRequest("POST", window.location.href, {
                success: function(o) {
                    var res = FF.util.getEvalRes(o);
                    if (res.status) {
                        if (_65) {
                            window.location.href = _65;
                        } else {
                            FF.util.yFadeRemove(el, "li");
                        }
                    } else {
                        alert(res.msg);
                    }
                },
                failure: function(o) {}
            },
            _66);
        }
    };
    
    
    
    FF.widget.initStream = function() {
        var el = YAHOO.util.Dom.get("stream");
        if (!el) {
            return;
        }
        var _e3 = el.getElementsByTagName("li");
        YAHOO.util.Dom.addClass(_e3, "unlight");
        YAHOO.util.Event.on(_e3, "mouseover",
        function(e) {
            YAHOO.util.Dom.addClass(this, "light");
            YAHOO.util.Dom.removeClass(this, "unlight");
        });
        YAHOO.util.Event.on(_e3, "mouseout",
        function(e) {
            YAHOO.util.Dom.addClass(this, "unlight");
            YAHOO.util.Dom.removeClass(this, "light");
        });
    };
})();