/**
 * Twitter - http://twitter.com
 * Copyright (C) 2010 Twitter
 * SPRESSOOOOOOOOOOOOOOOOO
 *
 * V 2.2.5 Twitter search/profile/faves/list widget
 * http://twitter.com/widgets
 * For full documented source see http://twitter.com/javascripts/widgets/widget.js
 * Hosting and modifications of the original source IS allowed.
 */
/*Customised Twitter Search Widget Modifications by fatbellyman.com 03/2011- license as above
Please note - document.write does not work for html served as xml*/
TWTR = window.TWTR || {};
if (!Array.forEach) {
    Array.prototype.filter = function (E, F) {
        var D = F || window;
        var A = [];
        for (var C = 0, B = this.length; C < B; ++C) {
            if (!E.call(D, this[C], C, this)) {
                continue
            }
            A.push(this[C])
        }
        return A
    };
    Array.prototype.indexOf = function (B, C) {
        var C = C || 0;
        for (var A = 0; A < this.length; ++A) {
            if (this[A] === B) {
                return A
            }
        }
        return -1
    }
}(function () {
    if (TWTR && TWTR.Widget) {
        return
    }
    function B(D, G, C) {
        for (var F = 0, E = D.length; F < E; ++F) {
            G.call(C || window, D[F], F, D)
        }
    }
    function A(C, E, D) {
        this.el = C;
        this.prop = E;
        this.from = D.from;
        this.to = D.to;
        this.time = D.time;
        this.callback = D.callback;
        this.animDiff = this.to - this.from
    }
    A.canTransition = function () {
        var C = document.createElement("twitter");
        C.style.cssText = "-webkit-transition: all .5s linear;";
        return !!C.style.webkitTransitionProperty
    }();
    A.prototype._setStyle = function (C) {
        switch (this.prop) {
        case "opacity":
            this.el.style[this.prop] = C;
            //this.el.style.filter = "alpha(opacity=" + C * 100 + ")";
			//GH - A bodge to work around the problem of MSIE poor font rendering on opacity transitions
			var browserName=window.navigator.appName;
			var browserVer=parseInt(window.navigator.appVersion);
			if (browserName=="Microsoft Internet Explorer" && browserVer <=9){
					this.el.style.filter = "";
					}else{
						this.el.style.filter = "alpha(opacity=" + C * 100 + ")";
					}
			//GH - End Bodge *Doesn't work for MSIE compatability mode
            break;
        default:
            this.el.style[this.prop] = C + "px";
            break
        }
    };
    A.prototype._animate = function () {
        var C = this;
        this.now = new Date();
        this.diff = this.now - this.startTime;
        if (this.diff > this.time) {
            this._setStyle(this.to);
            if (this.callback) {
                this.callback.call(this)
            }
            clearInterval(this.timer);
            return
        }
        this.percentage = (Math.floor((this.diff / this.time) * 100) / 100);
        this.val = (this.animDiff * this.percentage) + this.from;
        this._setStyle(this.val)
    };
    A.prototype.start = function () {
        var C = this;
        this.startTime = new Date();
        this.timer = setInterval(function () {
            C._animate.call(C)
        }, 15)
    };
    TWTR.Widget = function (C) {
        this.init(C)
    };
    (function () {
        var R = {};
        var O = location.protocol.match(/https/);
        var Q = /^.+\/profile_images/;
        var W = "https://s3.amazonaws.com/twitter_production/profile_images";
        var X = function (h) {
            return O ? h.replace(Q, W) : h
        };
        var g = {};
        var e = function (i) {
            var h = g[i];
            if (!h) {
                h = new RegExp("(?:^|\\s+)" + i + "(?:\\s+|$)");
                g[i] = h
            }
            return h
        };
        var D = function (m, q, n, o) {
            var q = q || "*";
            var n = n || document;
            var j = [],
                h = n.getElementsByTagName(q),
                p = e(m);
            for (var k = 0, l = h.length; k < l; ++k) {
                if (p.test(h[k].className)) {
                    j[j.length] = h[k];
                    if (o) {
                        o.call(h[k], h[k])
                    }
                }
            }
            return j
        };
        var f = function () {
            var h = navigator.userAgent;
            return {
                ie: h.match(/MSIE\s([^;]*)/)
            }
        }();
        var H = function (h) {
            if (typeof h == "string") {
                return document.getElementById(h)
            }
            return h
        };
        var Z = function (h) {
            return h.replace(/^\s+|\s+$/g, "")
        };
        var V = function () {
            var h = self.innerHeight;
            var i = document.compatMode;
            if ((i || f.ie)) {
                h = (i == "CSS1Compat") ? document.documentElement.clientHeight : document.body.clientHeight
            }
            return h
        };
        var d = function (j, h) {
            var i = j.target || j.srcElement;
            return h(i)
        };
        var T = function (i) {
            try {
                if (i && 3 == i.nodeType) {
                    return i.parentNode
                } else {
                    return i
                }
            } catch (h) {}
        };
        var U = function (i) {
            var h = i.relatedTarget;
            if (!h) {
                if (i.type == "mouseout") {
                    h = i.toElement
                } else {
                    if (i.type == "mouseover") {
                        h = i.fromElement
                    }
                }
            }
            return T(h)
        };
        var a = function (i, h) {
            h.parentNode.insertBefore(i, h.nextSibling)
        };
        var b = function (i) {
            try {
                i.parentNode.removeChild(i)
            } catch (h) {}
        };
        var Y = function (h) {
            return h.firstChild
        };
        var C = function (j) {
            var i = U(j);
            while (i && i != this) {
                try {
                    i = i.parentNode
                } catch (h) {
                    i = this
                }
            }
            if (i != this) {
                return true
            }
            return false
        };
        var G = function () {
            if (document.defaultView && document.defaultView.getComputedStyle) {
                return function (i, l) {
                    var k = null;
                    var j = document.defaultView.getComputedStyle(i, "");
                    if (j) {
                        k = j[l]
                    }
                    var h = i.style[l] || k;
                    return h
                }
            } else {
                if (document.documentElement.currentStyle && f.ie) {
                    return function (h, j) {
                        var i = h.currentStyle ? h.currentStyle[j] : null;
                        return (h.style[j] || i)
                    }
                }
            }
        }();
        var c = {
            has: function (h, i) {
                return new RegExp("(^|\\s)" + i + "(\\s|$)").test(H(h).className)
            },
            add: function (h, i) {
                if (!this.has(h, i)) {
                    H(h).className = Z(H(h).className) + " " + i
                }
            },
            remove: function (h, i) {
                if (this.has(h, i)) {
                    H(h).className = H(h).className.replace(new RegExp("(^|\\s)" + i + "(\\s|$)", "g"), "")
                }
            }
        };
        var E = {
            add: function (j, i, h) {
                if (j.addEventListener) {
                    j.addEventListener(i, h, false)
                } else {
                    j.attachEvent("on" + i, function () {
                        h.call(j, window.event)
                    })
                }
            },
            remove: function (j, i, h) {
                if (j.removeEventListener) {
                    j.removeEventListener(i, h, false)
                } else {
                    j.detachEvent("on" + i, h)
                }
            }
        };
        var N = function () {
            function i(k) {
                return parseInt((k).substring(0, 2), 16)
            }
            function h(k) {
                return parseInt((k).substring(2, 4), 16)
            }
            function j(k) {
                return parseInt((k).substring(4, 6), 16)
            }
            return function (k) {
                return [i(k), h(k), j(k)]
            }
        }();
        var I = {
            bool: function (h) {
                return typeof h === "boolean"
            },
            def: function (h) {
                return !(typeof h === "undefined")
            },
            number: function (h) {
                return typeof h === "number" && isFinite(h)
            },
            string: function (h) {
                return typeof h === "string"
            },
            fn: function (h) {
                return typeof h === "function"
            },
            array: function (h) {
                if (h) {
                    return I.number(h.length) && I.fn(h.splice)
                }
                return false
            }
        };
        var M = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
        var S = function (k) {
            var n = new Date(k);
            if (f.ie) {
                n = Date.parse(k.replace(/( \+)/, " UTC$1"))
            }
            var i = "";
            var h = function () {
                var o = n.getHours();
                if (o > 0 && o < 13) {
                    i = "am";
                    return o
                } else {
                    if (o < 1) {
                        i = "am";
                        return 12
                    } else {
                        i = "pm";
                        return o - 12
                    }
                }
            }();
            var j = n.getMinutes();
            var m = n.getSeconds();

            function l() {
                var o = new Date();
                if (o.getDate() != n.getDate() || o.getYear() != n.getYear() || o.getMonth() != n.getMonth()) {
                    return " - " + M[n.getMonth()] + " " + n.getDate() + ", " + n.getFullYear()
                } else {
                    return ""
                }
            }
            return h + ":" + j + i + l()
        };
        var K = function (n) {
            var p = new Date();
            var l = new Date(n);
            if (f.ie) {
                l = Date.parse(n.replace(/( \+)/, " UTC$1"))
            }
            var o = p - l;
            var i = 1000,
                j = i * 60,
                k = j * 60,
                m = k * 24,
                h = m * 7;
            if (isNaN(o) || o < 0) {
                return ""
            }
            if (o < i * 2) {
                return "right now"
            }
            if (o < j) {
                return Math.floor(o / i) + " seconds ago"
            }
            if (o < j * 2) {
                return "about 1 minute ago"
            }
            if (o < k) {
                return Math.floor(o / j) + " minutes ago"
            }
            if (o < k * 2) {
                return "about 1 hour ago"
            }
            if (o < m) {
                return Math.floor(o / k) + " hours ago"
            }
            if (o > m && o < m * 2) {
                return "yesterday"
            }
            if (o < m * 365) {
                return Math.floor(o / m) + " days ago"
            } else {
                return "over a year ago"
            }
        };
        var F = {
            link: function (h) {
                return h.replace(/\b(((https*\:\/\/)|www\.)[^\"\']+?)(([!?,.\)]+)?(\s|$))/g, function (n, m, k, j, i) {
                    var l = k.match(/w/) ? "http://" : "";
                    return '<a class="twtr-hyperlink" target="_blank" href="' + l + m + '">' + ((m.length > 25) ? m.substr(0, 24) + "..." : m) + "</a>" + i
                })
            },
            at: function (h) {
                return h.replace(/\B[@]([a-zA-Z0-9_]{1,20})/g, function (i, j) {
                    return '@<a target="_blank" class="twtr-atreply" href="http://twitter.com/' + j + '">' + j + "</a>"
                })
            },
            list: function (h) {
                return h.replace(/\B[@]([a-zA-Z0-9_]{1,20}\/\w+)/g, function (i, j) {
                    return '@<a target="_blank" class="twtr-atreply" href="http://twitter.com/' + j + '">' + j + "</a>"
                })
            },
            hash: function (h) {
                return h.replace(/(^|\s+)#(\w+)/gi, function (i, j, k) {
                    return j + '<a target="_blank" class="twtr-hashtag" href="http://twitter.com/search?q=%23' + k + '">#' + k + "</a>"
                })
            },
            clean: function (h) {
                return this.hash(this.at(this.list(this.link(h))))
            }
        };

        function P(i, j, h) {
            this.job = i;
            this.decayFn = j;
            this.interval = h;
            this.decayRate = 1;
            this.decayMultiplier = 1.25;
            this.maxDecayTime = 3 * 60 * 1000
        }
        P.prototype = {
            start: function () {
                this.stop().run();
                return this
            },
            stop: function () {
                if (this.worker) {
                    window.clearTimeout(this.worker)
                }
                return this
            },
            run: function () {
                var h = this;
                this.job(function () {
                    h.decayRate = h.decayFn() ? Math.max(1, h.decayRate / h.decayMultiplier) : h.decayRate * h.decayMultiplier;
                    var i = h.interval * h.decayRate;
                    i = (i >= h.maxDecayTime) ? h.maxDecayTime : i;
                    i = Math.floor(i);
                    h.worker = window.setTimeout(function () {
                        h.run.call(h)
                    }, i)
                })
            },
            destroy: function () {
                this.stop();
                this.decayRate = 1;
                return this
            }
        };

        function J(i, h, j) {
            this.time = i || 6000;
            this.loop = h || false;
            this.repeated = 0;
            this.callback = j;
            this.haystack = []
        }
        J.prototype = {
            set: function (h) {
                this.haystack = h
            },
            add: function (h) {
                this.haystack.unshift(h)
            },
            start: function () {
                if (this.timer) {
                    return this
                }
                this._job();
                var h = this;
                this.timer = setInterval(function () {
                    h._job.call(h)
                }, this.time);
                return this
            },
            stop: function () {
                if (this.timer) {
                    window.clearInterval(this.timer);
                    this.timer = null
                }
                return this
            },
            _next: function () {
                var h = this.haystack.shift();
                if (h && this.loop) {
                    this.haystack.push(h)
                }
                return h || null
            },
            _job: function () {
                var h = this._next();
                if (h) {
                    this.callback(h)
                }
                return this
            }
        };

        function L(j) {
            function h() {
                if (j.needle.metadata && j.needle.metadata.result_type && j.needle.metadata.result_type == "popular") {
                    return '<span class="twtr-popular">' + j.needle.metadata.recent_retweets + "+ recent retweets</span>"
                } else {
                    return ""
                }
            }
            var i = '<div class="twtr-tweet-wrap"><div class="twtr-avatar"><div class="twtr-img"><a target="_blank" href="http://twitter.com/' + j.user + '"><img alt="' + j.user + ' profile" src="' + X(j.avatar) + '"></a></div></div><div class="twtr-tweet-text"><p><a target="_blank" href="http://twitter.com/' + j.user + '" class="twtr-user">' + j.user + "</a> " + j.tweet + '<em><a target="_blank" class="twtr-timestamp" time="' + j.timestamp + '" href="http://twitter.com/' + j.user + "/status/" + j.id + '">' + j.created_at + '</a> &middot; <a target="_blank" class="twtr-reply" href="http://twitter.com/?status=@' + j.user + "%20&in_reply_to_status_id=" + j.id + "&in_reply_to=" + j.user + '">reply</a></em> ' + h() + "</p></div></div>";
            var k = document.createElement("div");
            k.id = "tweet-id-" + ++L._tweetCount;
            k.className = "twtr-tweet";
            k.innerHTML = i;
            this.element = k
        }
        L._tweetCount = 0;
        R.loadStyleSheet = function (j, i) {
            if (!TWTR.Widget.loadingStyleSheet) {
                TWTR.Widget.loadingStyleSheet = true;
                var h = document.createElement("link");
                h.href = j;
                h.rel = "stylesheet";
                h.type = "text/css";
                document.getElementsByTagName("head")[0].appendChild(h);
                var k = setInterval(function () {
                    var l = G(i, "position");
                    if (l == "relative") {
                        clearInterval(k);
                        k = null;
                        TWTR.Widget.hasLoadedStyleSheet = true
                    }
                }, 50)
            }
        };
        (function () {
            var h = false;
            R.css = function (k) {
                var j = document.createElement("style");
                j.type = "text/css";
                if (f.ie) {
                    j.styleSheet.cssText = k
                } else {
                    var l = document.createDocumentFragment();
                    l.appendChild(document.createTextNode(k));
                    j.appendChild(l)
                }
                function i() {
                    document.getElementsByTagName("head")[0].appendChild(j)
                }
                if (!f.ie || h) {
                    i()
                } else {
                    window.attachEvent("onload", function () {
                        h = true;
                        i()
                    })
                }
            }
        })();
        TWTR.Widget.isLoaded = false;
        TWTR.Widget.loadingStyleSheet = false;
        TWTR.Widget.hasLoadedStyleSheet = false;
        TWTR.Widget.WIDGET_NUMBER = 0;
        TWTR.Widget.matches = {
            mentions: /^@[a-zA-Z0-9_]{1,20}\b/,
            any_mentions: /\b@[a-zA-Z0-9_]{1,20}\b/
        };
        TWTR.Widget.jsonP = function (i, k) {
            var h = document.createElement("script");
            var j = document.getElementsByTagName("head")[0];
            h.type = "text/javascript";
            h.src = i;
            j.insertBefore(h, j.firstChild);
            k(h);
            return h
        };
        TWTR.Widget.prototype = function () {
            var k = O ? "https://" : "http://";
            var n = window.location.hostname.match(/twitter\.com/) ? (window.location.hostname + ":" + window.location.port) : "twitter.com";
            var m = k + "search." + n + "/search.";
            var o = k + "api." + n + "/1/statuses/user_timeline.";
            var j = k + n + "/favorites/";
            var l = k + "api." + n + "/1/";
            var i = 25000;
            var h = O ? "https://twitter-widgets.s3.amazonaws.com/j/1/default.gif" : "http://widgets.twimg.com/j/1/default.gif";
            return {
                init: function (q) {
                    var p = this;
                    this._widgetNumber = ++TWTR.Widget.WIDGET_NUMBER;
                    TWTR.Widget["receiveCallback_" + this._widgetNumber] = function (r) {
                        p._prePlay.call(p, r)
                    };
                    this._cb = "TWTR.Widget.receiveCallback_" + this._widgetNumber;
                    this.opts = q;
                    this._base = m;
                    this._isRunning = false;
                    this._hasOfficiallyStarted = false;
                    this._hasNewSearchResults = false;
                    this._rendered = false;
                    this._profileImage = false;
                    this._isCreator = !! q.creator;
                    this._setWidgetType(q.type);
                    this.timesRequested = 0;
                    this.runOnce = false;
                    this.newResults = false;
                    this.results = [];
                    this.jsonMaxRequestTimeOut = 19000;
                    this.showedResults = [];
                    this.sinceId = 1;
                    this.source = "TWITTERINC_WIDGET";
                    this.id = q.id || "twtr-widget-" + this._widgetNumber;
                    this.tweets = 0;
                    this.setDimensions(q.width, q.height);
                    this.interval = q.interval || 6000;
                    this.format = "json";
                    this.rpp = q.rpp || 50;
                    this.subject = q.subject || "";
                    this.title = q.title || "";
                    this.setFooterText(q.footer);
                    this.setSearch(q.search);
                    this._setUrl();
                    this.theme = q.theme ? q.theme : this._getDefaultTheme();
                    if (!q.id) {
                        document.write('<div class="twtr-widget" id="' + this.id + '"></div>')
                    }
                    this.widgetEl = H(this.id);
                    if (q.id) {
                        c.add(this.widgetEl, "twtr-widget")
                    }
                    if (q.version >= 2 && !TWTR.Widget.hasLoadedStyleSheet) {
                        if (O) {
						//files are referenced from the page this script is launched from, not relative to its path in the file system
                            R.loadStyleSheet("/css/widget.css", this.widgetEl)
                        } else {
                            if (q.creator) {
                                R.loadStyleSheet("/css/widget.css", this.widgetEl)
                            } else {
                                R.loadStyleSheet("css/widget.css", this.widgetEl)
                            }
                        }
                    }
                    this.occasionalJob = new P(function (r) {
                        p.decay = r;
                        p._getResults.call(p)
                    }, function () {
                        return p._decayDecider.call(p)
                    }, i);
					//features section
                    this._ready = I.fn(q.ready) ? q.ready : function () {};
                    this._isRelativeTime = true;
                    this._tweetFilter = false;
                    this._avatars = true;
                    this._isFullScreen = false;
                    this._isLive = true;
                    this._isScroll = false;
                    this._loop = true;
                    this._showTopTweets = (this._isSearchWidget) ? true : false;
                    this._behavior = "default";
                    this.setFeatures(this.opts.features);
                    this.intervalJob = new J(this.interval, this._loop, function (r) {
                        p._normalizeTweet(r)
                    });
                    return this
                },
                setDimensions: function (p, q) {
                    this.wh = (p && q) ? [p, q] : [250, 300];
                    if (p == "auto" || p == "100%") {
                        this.wh[0] = "100%"
                    } else {
                        this.wh[0] = ((this.wh[0] < 150) ? 150 : this.wh[0]) + "px"
                    }
                    this.wh[1] = ((this.wh[1] < 100) ? 100 : this.wh[1]) + "px";
                    return this
                },
                setRpp: function (p) {
                    var p = parseInt(p);
                    this.rpp = (I.number(p) && (p > 0 && p <= 100)) ? p : 30;
                    return this
                },
                _setWidgetType: function (p) {
                    this._isSearchWidget = false, this._isProfileWidget = false, this._isFavsWidget = false, this._isListWidget = false;
                    switch (p) {
                    case "profile":
                        this._isProfileWidget = true;
                        break;
                    case "search":
                        this._isSearchWidget = true, this.search = this.opts.search;
                        break;
                    case "faves":
                    case "favs":
                        this._isFavsWidget = true;
                        break;
                    case "list":
                    case "lists":
                        this._isListWidget = true;
                        break
                    }
                    return this
                },
                setFeatures: function (q) {
                    if (q) {
                        if (I.def(q.filters)) {
                            this._tweetFilter = q.filters
                        }
                        if (I.def(q.dateformat)) {
                            this._isRelativeTime = !! (q.dateformat !== "absolute")
                        }
                        if (I.def(q.fullscreen) && I.bool(q.fullscreen)) {
                            if (q.fullscreen) {
                                this._isFullScreen = true;
                                this.wh[0] = "100%";
                                this.wh[1] = (V() - 90) + "px";
                                var r = this;
                                E.add(window, "resize", function (u) {
                                    r.wh[1] = V();
                                    r._fullScreenResize()
                                })
                            }
                        }
                        if (I.def(q.loop) && I.bool(q.loop)) {
                            this._loop = q.loop
                        }
                        if (I.def(q.behavior) && I.string(q.behavior)) {
                            switch (q.behavior) {
                            case "all":
                                this._behavior = "all";
                                break;
                            case "preloaded":
                                this._behavior = "preloaded";
                                break;
                            default:
                                this._behavior = "default";
                                break
                            }
                        }
                        if (I.def(q.toptweets) && I.bool(q.toptweets)) {
                            this._showTopTweets = q.toptweets;
                            var p = (this._showTopTweets) ? "inline-block" : "none";
                            R.css("#" + this.id + " .twtr-popular { display: " + p + "; }")
                        }
                        if (!I.def(q.toptweets)) {
                            this._showTopTweets = true;
                            var p = (this._showTopTweets) ? "inline-block" : "none";
                            R.css("#" + this.id + " .twtr-popular { display: " + p + "; }")
                        }
                        if (I.def(q.avatars) && I.bool(q.avatars)) {
                            if (!q.avatars) {
                                R.css("#" + this.id + " .twtr-avatar, #" + this.id + " .twtr-user { display: none; } #" + this.id + " .twtr-tweet-text { margin-left: 0; }");
                                this._avatars = false
                            } else {
                                var s = (this._isFullScreen) ? "90px" : "40px";
                                R.css("#" + this.id + " .twtr-avatar { display: block; } #" + this.id + " .twtr-user { display: inline; } #" + this.id + " .twtr-tweet-text { margin-left: " + s + "; }");
                                this._avatars = true
                            }
                        } else {
                            if (this._isProfileWidget) {
                                this.setFeatures({
                                    avatars: false
                                });
                                this._avatars = false
                            } else {
                                this.setFeatures({
                                    avatars: true
                                });
                                this._avatars = true
                            }
                        }
                        if (I.def(q.hashtags) && I.bool(q.hashtags)) {
                            (!q.hashtags) ? R.css("#" + this.id + " a.twtr-hashtag { display: none; }") : ""
                        }
                        if (I.def(q.timestamp) && I.bool(q.timestamp)) {
                            var t = q.timestamp ? "block" : "none";
                            R.css("#" + this.id + " em { display: " + t + "; }")
                        }
                        if (I.def(q.live) && I.bool(q.live)) {
                            this._isLive = q.live
                        }
                        if (I.def(q.scrollbar) && I.bool(q.scrollbar)) {
                            this._isScroll = q.scrollbar
                        }
                    } else {
                        if (this._isProfileWidget) {
                            this.setFeatures({
                                avatars: false
                            });
                            this._avatars = false
                        }
                        if (this._isProfileWidget || this._isFavsWidget) {
                            this.setFeatures({
                                behavior: "all"
                            })
                        }
                    }
                    return this
                },
                _fullScreenResize: function () {
                    var p = D("twtr-timeline", "div", document.body, function (q) {
                        q.style.height = (V() - 90) + "px"
                    })
                },
                setTweetInterval: function (p) {
                    this.interval = p;
                    return this
                },
                setBase: function (p) {
                    this._base = p;
                    return this
                },
                setUser: function (q, p) {
                    this.username = q;
                    this.realname = p || " ";
                    if (this._isFavsWidget) {
                        this.setBase(j + q + ".")
                    } else {
                        if (this._isProfileWidget) {
                            this.setBase(o + this.format + "?screen_name=" + q)
                        }
                    }
                    this.setSearch(" ");
                    return this
                },
                setList: function (q, p) {
                    this.listslug = p.replace(/ /g, "-").toLowerCase();
                    this.username = q;
                    this.setBase(l + q + "/lists/" + this.listslug + "/statuses.");
                    this.setSearch(" ");
                    return this
                },
                setProfileImage: function (p) {
                    this._profileImage = p;
                    this.byClass("twtr-profile-img", "img").src = X(p);
                    this.byClass("twtr-profile-img-anchor", "a").href = "http://twitter.com/" + this.username;
                    return this
                },
                setTitle: function (p) {
                    this.title = p;
                    this.widgetEl.getElementsByTagName("h3")[0].innerHTML = this.title;
                    return this
                },
                setCaption: function (p) {
                    this.subject = p;
                    this.widgetEl.getElementsByTagName("h4")[0].innerHTML = this.subject;
                    return this
                },
                setFooterText: function (p) {
                    this.footerText = (I.def(p) && I.string(p)) ? p : "Join the conversation";
                    if (this._rendered) {
                        this.byClass("twtr-join-conv", "a").innerHTML = this.footerText
                    }
                    return this
                },
                setSearch: function (q) {
                    this.searchString = q || "";
                    this.search = encodeURIComponent(this.searchString);
                    this._setUrl();
                    if (this._rendered) {
                        var p = this.byClass("twtr-join-conv", "a");
                        p.href = "http://twitter.com/" + this._getWidgetPath()
                    }
                    return this
                },
                _getWidgetPath: function () {
                    if (this._isProfileWidget) {
                        return this.username
                    } else {
                        if (this._isFavsWidget) {
                            return this.username + "/favorites"
                        } else {
                            if (this._isListWidget) {
                                return this.username + "/lists/" + this.listslug
                            } else {
                                //return "#search?q=" + this.search
                                return "search?q=" + this.search//GH correct ill-formed search query at footer text link
                            }
                        }
                    }
                },
                _setUrl: function () {
                    var q = this;

                    function p() {
                        return "&" + (+new Date) + "=cachebust"
                    }
                    function r() {
                        return (q.sinceId == 1) ? "" : "&since_id=" + q.sinceId + "&refresh=true"
                    }
                    if (this._isProfileWidget) {
                        this.url = this._base + "&callback=" + this._cb + "&include_rts=true&count=" + this.rpp + r() + "&clientsource=" + this.source
                    } else {
                        if (this._isFavsWidget || this._isListWidget) {
                            this.url = this._base + this.format + "?callback=" + this._cb + r() + "&include_rts=true&clientsource=" + this.source
                        } else {
                            this.url = this._base + this.format + "?q=" + this.search + "&include_rts=true&callback=" + this._cb + "&rpp=" + this.rpp + r() + "&clientsource=" + this.source;
                            if (!this.runOnce) {
                                this.url += "&result_type=mixed"
                            }
                        }
                    }
                    this.url += p();
                    return this
                },
                _getRGB: function (p) {
                    return N(p.substring(1, 7))
                },
                setTheme: function (u, p) {
                    var s = this;
                    var q = " !important";
                    var t = ((window.location.hostname.match(/twitter\.com/)) && (window.location.pathname.match(/goodies/)));
                    if (p || t) {
                        q = ""
                    }
                    this.theme = {
                        shell: {
                            background: function () {
                                return u.shell.background || s._getDefaultTheme().shell.background
                            }(),
                            color: function () {
                                return u.shell.color || s._getDefaultTheme().shell.color
                            }()
                        },
                        tweets: {
                            background: function () {
                                return u.tweets.background || s._getDefaultTheme().tweets.background
                            }(),
                            color: function () {
                                return u.tweets.color || s._getDefaultTheme().tweets.color
                            }(),
                            links: function () {
                                return u.tweets.links || s._getDefaultTheme().tweets.links
                            }()
                        }
                    };
                    var r = "#" + this.id + " .twtr-doc,                      #" + this.id + " .twtr-hd a,                      #" + this.id + " h3,                      #" + this.id + " h4,                      #" + this.id + " .twtr-popular {            background-color: " + this.theme.shell.background + q + ";            color: " + this.theme.shell.color + q + ";          }          #" + this.id + " .twtr-popular {            color: " + this.theme.tweets.color + q + ";            background-color: rgba(" + this._getRGB(this.theme.shell.background) + ", .3)" + q + ";          }          #" + this.id + " .twtr-tweet a {            color: " + this.theme.tweets.links + q + ";          }          #" + this.id + " .twtr-bd, #" + this.id + " .twtr-timeline i a,           #" + this.id + " .twtr-bd p {            color: " + this.theme.tweets.color + q + ";          }          #" + this.id + " .twtr-new-results,           #" + this.id + " .twtr-results-inner,           #" + this.id + " .twtr-timeline {            background: " + this.theme.tweets.background + q + ";          }";
                    if (f.ie) {
                        r += "#" + this.id + " .twtr-tweet { background: " + this.theme.tweets.background + q + "; }"
                    }
                    R.css(r);
                    return this
                },
                byClass: function (s, p, q) {
                    var r = D(s, p, H(this.id));
                    return (q) ? r : r[0]
                },
                render: function () {
                    var r = this;
                    if (!TWTR.Widget.hasLoadedStyleSheet) {
                        window.setTimeout(function () {
                            r.render.call(r)
                        }, 50);
                        return this
                    }
                    this.setTheme(this.theme, this._isCreator);
                    if (this._isProfileWidget) {
                        c.add(this.widgetEl, "twtr-widget-profile")
                    }
                    if (this._isScroll) {
                        c.add(this.widgetEl, "twtr-scroll")
                    }
                    if (!this._isLive && !this._isScroll) {
                        this.wh[1] = "auto"
                    }
                    if (this._isSearchWidget && this._isFullScreen) {
                        //document.title = "Twitter search: " + escape(this.searchString)
                        document.title = "Twitter search: " + (this.searchString)//GH - user would only affect their own browser with weird chars
                    }
                    this.widgetEl.innerHTML = this._getWidgetHtml();
                    var q = this.byClass("twtr-timeline", "div");
                    if (this._isLive && !this._isFullScreen) {
                        var s = function (t) {
                            if (r._behavior === "all") {
                                return
                            }
                            if (C.call(this, t)) {
                                r.pause.call(r)
                            }
                        };
                        var p = function (t) {
                            if (r._behavior === "all") {
                                return
                            }
                            if (C.call(this, t)) {
                                r.resume.call(r)
                            }
                        };
                        this.removeEvents = function () {
                            E.remove(q, "mouseover", s);
                            E.remove(q, "mouseout", p)
                        };
                        E.add(q, "mouseover", s);
                        E.add(q, "mouseout", p)
                    }
                    this._rendered = true;
                    this._ready();
                    return this
                },
                removeEvents: function () {},
                _getDefaultTheme: function () {
                    return {
                        shell: {
                            background: "#8ec1da",
                            color: "#ffffff"
                        },
                        tweets: {
                            background: "#ffffff",
                            color: "#444444",
                            links: "#1985b5"
                        }
                    }
                },
                _getWidgetHtml: function () {
                    var r = this;

                    function t() {
                        if (r._isProfileWidget) {
                            return '<a target="_blank" href="http://twitter.com/" class="twtr-profile-img-anchor"><img alt="profile" class="twtr-profile-img" src="' + h + '"></a><h3></h3><h4></h4>'
                        } else {
                            return "<h3>" + r.title + "</h3><h4>" + r.subject + "</h4>"
                        }
                    }
                    function q() {
                        return r._isFullScreen ? " twtr-fullscreen" : ""
                    }
                    //var s = O ? "https://twitter-widgets.s3.amazonaws.com/i/widget-logo.png" : "http://widgets.twimg.com/i/widget-logo.png";
					//files are referenced from the page this script is launched, not relative to its path in the file system
					//If this file is be called from different directory depths, use a url as a path
                    var s = "images/widget-logo.png";
                    if (this._isFullScreen) {
                        //s = "https://twitter-widgets.s3.amazonaws.com/i/widget-logo-fullscreen.png"
                        s = "images/widget-logo-fullscreen.png"
                    }
                    var p = '<div class="twtr-doc' + q() + '" style="width: ' + this.wh[0] + ';"><div class="twtr-hd">' + t() + '             </div><div class="twtr-bd"><div class="twtr-timeline" style="height: ' + this.wh[1] + ';"><div class="twtr-tweets"><div class="twtr-reference-tweet"></div><!--tweets show here--></div></div></div><div class="twtr-ft"><div><a target="_blank" href="http://twitter.com"><img alt="" src="' + s + '"></a><span><a target="_blank" class="twtr-join-conv" style="color:' + this.theme.shell.color + '" href="http://twitter.com/' + this._getWidgetPath() + '">' + this.footerText + "</a></span></div></div></div>";
                    return p
                },
                _appendTweet: function (p) {
                    this._insertNewResultsNumber();
                    a(p, this.byClass("twtr-reference-tweet", "div"));
                    return this
                },
                _slide: function (q) {
                    var r = this;
                    var p = Y(q).offsetHeight;
                    if (this.runOnce) {
                        new A(q, "height", {
                            from: 0,
                            to: p,
                            time: 500,
                            callback: function () {
                                r._fade.call(r, q)
                            }
                        }).start()
                    }
                    return this
                },
                _fade: function (p) {
                    var q = this;
                    if (A.canTransition) {
                        p.style.webkitTransition = "opacity 0.5s ease-out";
                        p.style.opacity = 1;
                        return this
                    }
                    new A(p, "opacity", {
                        from: 0,
                        to: 1,
                        time: 500
                    }).start();
                    return this
                },
                _chop: function () {
                    if (this._isScroll) {
                        return this
                    }
                    var u = this.byClass("twtr-tweet", "div", true);
                    var v = this.byClass("twtr-new-results", "div", true);
                    if (u.length) {
                        for (var r = u.length - 1; r >= 0; r--) {
                            var t = u[r];
                            var s = parseInt(t.offsetTop);
                            if (s > parseInt(this.wh[1])) {
                                b(t)
                            } else {
                                break
                            }
                        }
                        if (v.length > 0) {
                            var p = v[v.length - 1];
                            var q = parseInt(p.offsetTop);
                            if (q > parseInt(this.wh[1])) {
                                b(p)
                            }
                        }
                    }
                    return this
                },
                _appendSlideFade: function (q) {
                    var p = q || this.tweet.element;
                    this._chop()._appendTweet(p)._slide(p);
                    return this
                },
                _createTweet: function (p) {
                    p.timestamp = p.created_at;
                    p.created_at = this._isRelativeTime ? K(p.created_at) : S(p.created_at);
                    this.tweet = new L(p);
                    if (this._isLive && this.runOnce) {
                        this.tweet.element.style.opacity = 0;
                        this.tweet.element.style.filter = "alpha(opacity:0)";
                        this.tweet.element.style.height = "0"
                    }
                    return this
                },
                _getResults: function () {
                    var p = this;
                    this.timesRequested++;
                    this.jsonRequestRunning = true;
                    this.jsonRequestTimer = window.setTimeout(function () {
                        if (p.jsonRequestRunning) {
                            clearTimeout(p.jsonRequestTimer);
                            p.jsonRequestTimer = null
                        }
                        p.jsonRequestRunning = false;
                        b(p.scriptElement);
                        p.newResults = false;
                        p.decay()
                    }, this.jsonMaxRequestTimeOut);
                    TWTR.Widget.jsonP(p.url, function (q) {
                        p.scriptElement = q
                    })
                },
                clear: function () {
                    var q = this.byClass("twtr-tweet", "div", true);
                    var p = this.byClass("twtr-new-results", "div", true);
                    q = q.concat(p);
                    B(q, function (r) {
                        b(r)
                    });
                    return this
                },
                _sortByMagic: function (p) {
                    var q = this;
                    if (this._tweetFilter) {
                        if (this._tweetFilter.negatives) {
                            p = p.filter(function (r) {
                                if (!q._tweetFilter.negatives.test(r.text)) {
                                    return r
                                }
                            })
                        }
                        if (this._tweetFilter.positives) {
                            p = p.filter(function (r) {
                                if (q._tweetFilter.positives.test(r.text)) {
                                    return r
                                }
                            })
                        }
                    }
                    switch (this._behavior) {
                    case "all":
                        this._sortByLatest(p);
                        break;
                    case "preloaded":
                    default:
                        this._sortByDefault(p);
                        break
                    }
                    if (this._isLive && this._behavior !== "all") {
                        this.intervalJob.set(this.results);
                        this.intervalJob.start()
                    }
                    return this
                },
                _loadTopTweetsAtTop: function (r) {
                    var s = [],
                        t = [],
                        q = [];
                    B(r, function (u) {
                        if (u.metadata && u.metadata.result_type && u.metadata.result_type == "popular") {
                            t.push(u)
                        } else {
                            s.push(u)
                        }
                    });
                    var p = t.concat(s);
                    return p
                },
                _sortByLatest: function (p) {
                    this.results = p;
                    this.results = this.results.slice(0, this.rpp);
                    this.results = this._loadTopTweetsAtTop(this.results);
                    this.results.reverse();
                    return this
                },
                _sortByDefault: function (q) {
                    var r = this;
                    var p = function (t) {
                        return new Date(t).getTime()
                    };
                    this.results.unshift.apply(this.results, q);
                    B(this.results, function (t) {
                        if (!t.views) {
                            t.views = 0
                        }
                    });
                    this.results.sort(function (u, t) {
                        if (p(u.created_at) > p(t.created_at)) {
                            return -1
                        } else {
                            if (p(u.created_at) < p(t.created_at)) {
                                return 1
                            } else {
                                return 0
                            }
                        }
                    });
                    this.results = this.results.slice(0, this.rpp);
                    this.results = this._loadTopTweetsAtTop(this.results);
                    var s = this.results;
                    this.results = this.results.sort(function (u, t) {
                        if (u.views < t.views) {
                            return -1
                        } else {
                            if (u.views > t.views) {
                                return 1
                            }
                        }
                        return 0
                    });
                    if (!this._isLive) {
                        this.results.reverse()
                    }
                },
                _prePlay: function (q) {
                    if (this.jsonRequestTimer) {
                        clearTimeout(this.jsonRequestTimer);
                        this.jsonRequestTimer = null
                    }
                    if (!f.ie) {
                        b(this.scriptElement)
                    }
                    if (q.error) {
                        this.newResults = false
                    } else {
                        if (q.results && q.results.length > 0) {
                            this.response = q;
                            this.newResults = true;
                            this.sinceId = q.max_id_str;
                            this._sortByMagic(q.results);
                            if (this.isRunning()) {
                                this._play()
                            }
                        } else {
                            if ((this._isProfileWidget || this._isFavsWidget || this._isListWidget) && I.array(q) && q.length) {
                                this.newResults = true;
                                if (!this._profileImage && this._isProfileWidget) {
                                    var p = q[0].user.screen_name;
                                    this.setProfileImage(q[0].user.profile_image_url);
                                    this.setTitle(q[0].user.name);
                                    this.setCaption('<a target="_blank" href="http://twitter.com/' + p + '">' + p + "</a>")
                                }
                                this.sinceId = q[0].id_str;
                                this._sortByMagic(q);
                                if (this.isRunning()) {
                                    this._play()
                                }
                            } else {
                                this.newResults = false
                            }
                        }
                    }
                    this._setUrl();
                    if (this._isLive) {
                        this.decay()
                    }
                },
                _play: function () {
                    var p = this;
                    if (this.runOnce) {
                        this._hasNewSearchResults = true
                    }
                    if (this._avatars) {
                        this._preloadImages(this.results)
                    }
                    if (this._isRelativeTime && (this._behavior == "all" || this._behavior == "preloaded")) {
                        B(this.byClass("twtr-timestamp", "a", true), function (q) {
                            q.innerHTML = K(q.getAttribute("time"))
                        })
                    }
                    if (!this._isLive || this._behavior == "all" || this._behavior == "preloaded") {
                        B(this.results, function (r) {
                            if (r.retweeted_status) {
                                r = r.retweeted_status
                            }
                            if (p._isProfileWidget) {
                                r.from_user = r.user.screen_name;
                                r.profile_image_url = r.user.profile_image_url
                            }
                            if (p._isFavsWidget || p._isListWidget) {
                                r.from_user = r.user.screen_name;
                                r.profile_image_url = r.user.profile_image_url
                            }
                            r.id = r.id_str;
                            p._createTweet({
                                id: r.id,
                                user: r.from_user,
                                tweet: F.clean(r.text),
                                avatar: r.profile_image_url,
                                created_at: r.created_at,
                                needle: r
                            });
                            var q = p.tweet.element;
                            (p._behavior == "all") ? p._appendSlideFade(q) : p._appendTweet(q)
                        });
                        if (this._behavior != "preloaded") {
                            return this
                        }
                    }
                    return this
                },
                _normalizeTweet: function (q) {
                    var p = this;
                    q.views++;
                    if (this._isProfileWidget) {
                        q.from_user = p.username;
                        q.profile_image_url = q.user.profile_image_url
                    }
                    if (this._isFavsWidget || this._isListWidget) {
                        q.from_user = q.user.screen_name;
                        q.profile_image_url = q.user.profile_image_url
                    }
                    if (this._isFullScreen) {
                        q.profile_image_url = q.profile_image_url.replace(/_normal\./, "_bigger.")
                    }
                    this._createTweet({
                        id: q.id,
                        user: q.from_user,
                        tweet: F.clean(q.text),
                        avatar: q.profile_image_url,
                        created_at: q.created_at,
                        needle: q
                    })._appendSlideFade()
                },
                _insertNewResultsNumber: function () {
                    if (!this._hasNewSearchResults) {
                        this._hasNewSearchResults = false;
                        return
                    }
                    if (this.runOnce && this._isSearchWidget) {
                        var s = this.response.total > this.rpp ? this.response.total : this.response.results.length;
                        var p = s > 1 ? "s" : "";
                        var r = (this.response.warning && this.response.warning.match(/adjusted since_id/)) ? "more than" : "";
                        var q = document.createElement("div");
                        c.add(q, "twtr-new-results");
                        q.innerHTML = '<div class="twtr-results-inner"> &nbsp; </div><div class="twtr-results-hr"> &nbsp; </div><span>' + r + " <strong>" + s + "</strong> new tweet" + p + "</span>";
                        a(q, this.byClass("twtr-reference-tweet", "div"));
                        this._hasNewSearchResults = false
                    }
                },
                _preloadImages: function (p) {
                    if (this._isProfileWidget || this._isFavsWidget || this._isListWidget) {
                        B(p, function (r) {
                            var q = new Image();
                            q.src = X(r.user.profile_image_url)
                        })
                    } else {
                        B(p, function (q) {
                            (new Image()).src = X(q.profile_image_url)
                        })
                    }
                },
                _decayDecider: function () {
                    var p = false;
                    if (!this.runOnce) {
                        this.runOnce = true;
                        p = true
                    } else {
                        if (this.newResults) {
                            p = true
                        }
                    }
                    return p
                },
                start: function () {
                    var p = this;
                    if (!this._rendered) {
                        setTimeout(function () {
                            p.start.call(p)
                        }, 50);
                        return this
                    }
                    if (!this._isLive) {
                        this._getResults()
                    } else {
                        this.occasionalJob.start()
                    }
                    this._isRunning = true;
                    this._hasOfficiallyStarted = true;
                    return this
                },
                stop: function () {
                    this.occasionalJob.stop();
                    if (this.intervalJob) {
                        this.intervalJob.stop()
                    }
                    this._isRunning = false;
                    return this
                },
                pause: function () {
                    if (this.isRunning() && this.intervalJob) {
                        this.intervalJob.stop();
                        c.add(this.widgetEl, "twtr-paused");
                        this._isRunning = false
                    }
                    if (this._resumeTimer) {
                        clearTimeout(this._resumeTimer);
                        this._resumeTimer = null
                    }
                    return this
                },
                resume: function () {
                    var p = this;
                    if (!this.isRunning() && this._hasOfficiallyStarted && this.intervalJob) {
                        this._resumeTimer = window.setTimeout(function () {
                            p.intervalJob.start();
                            p._isRunning = true;
                            c.remove(p.widgetEl, "twtr-paused")
                        }, 2000)
                    }
                    return this
                },
                isRunning: function () {
                    return this._isRunning
                },
                destroy: function () {
                    this.stop();
                    this.clear();
                    this.runOnce = false;
                    this._hasOfficiallyStarted = false;
                    this._profileImage = false;
                    this._isLive = true;
                    this._tweetFilter = false;
                    this._isScroll = false;
                    this.newResults = false;
                    this._isRunning = false;
                    this.sinceId = 1;
                    this.results = [];
                    this.showedResults = [];
                    this.occasionalJob.destroy();
                    if (this.jsonRequestRunning) {
                        clearTimeout(this.jsonRequestTimer)
                    }
                    c.remove(this.widgetEl, "twtr-scroll");
                    this.removeEvents();
                    return this
                }
            }
        }()
    })()
})();
