var StockTwitsTrendingWidget={};
(function(){StockTwitsTrendingWidget.widgetHelpersUrl="http://stocktwits.com/addon/trending_widget/1";StockTwitsTrendingWidget.load=function(a){this.trendOpts=a=a||{};this.trendOpts.trendingStream=this.trendOpts.trendingStream||"daily";this.trendingStreamUrl="http://api.stocktwits.com/api/symbols/trending/";this.trendingStreamUrl+=a.trendingStream+".json";this.trendingStreamTitle="Top "+a.trendingStream+" trending tickers";if(this.trendOpts.title)this.trendingStreamTitle=this.trendOpts.title;a.limit=
a.limit||10;a.style=a.style||{};this.show();return this};StockTwitsTrendingWidget.show=function(){document.write("<!-- begin stocktwits trending widget --\>      <div id='StockTwits_trending_wrapper'>        <div id='stTrendingModuleHeader' class='stTrendingModuleHeader'>          <div id='stModuleTitle' class='stTitle'>"+this.trendingStreamTitle+"</div>        </div>        <div id='stTrendingModuleContent' class='stTrendingModuleContent'></div>        <div align='center' id='stTrendingModuleFooter' class='stTrendingModuleFooter'>          <a href='http://stocktwits.com/"+
this.urlTag+"' target='_blank'>            <img src='"+this.widgetHelpersUrl+"/stocktwits-logo.png' class='stLogo' />          </a>          <a href='http://stocktwits.com/signup"+this.urlTag+"' target='_blank' class='stTagline'>            Share Ideas &amp; Learn          </a>        </div>    </div>    <!-- end stocktwits trending widget --\>");this.injectCSS();var a=this.trendOpts.style,b=document.getElementById("StockTwits_trending_wrapper"),c=document.getElementById("stTrendingModuleHeader"),
d=document.getElementById("stTrendingModuleContent"),e=document.getElementById("stTrendingModuleFooter");if(a.background_color){b.style.backgroundColor=a.background_color;d.style.backgroundColor=a.background_color}if(a.border)b.style.border=a.border;if(a.width)b.style.width=a.width;if(a.height)b.style.height=a.height;if(a.font_size)b.style.fontSize=a.font_size;if(a.message_color)b.style.color=a.message_color;if(a.header_color){c.style.backgroundColor=a.header_color;c.style.background="none"}if(a.footer_color)e.style.backgroundColor=
a.footer_color;if(a.overflow)d.style.overflow=a.overflow;b="";if(a.link_color)b+="#StockTwits_trending_wrapper a { color: "+a.link_color+";} ";a=document.createElement("style");a.type="text/css";if(this.ie)a.styleSheet.cssText=b;else{c=document.createDocumentFragment();c.appendChild(document.createTextNode(b));a.appendChild(c)}document.getElementsByTagName("head")[0].appendChild(a);this.update()};StockTwitsTrendingWidget.injectCSS=function(){var a=document.createElement("link");a.setAttribute("rel",
"stylesheet");a.setAttribute("type","text/css");a.setAttribute("href",this.widgetHelpersUrl+"/trendingStocktwits.css");document.getElementsByTagName("head")[0].appendChild(a)};StockTwitsTrendingWidget.getJSONP=function(a,b){var c=document.createElement("script");c.src=a;c.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(c);this._JSONPScript=c;this._JSONPCallback=b};StockTwitsTrendingWidget.getJSONPCallback=function(a){this._JSONPCallback.call(this,a);this._JSONPCallback=
undefined;try{this._JSONPScript.parentNode.removeChild(this._JSONPScript)}catch(b){}};StockTwitsTrendingWidget.update=function(){var a=this;this.getJSONP(this.trendingStreamUrl+"?callback=StockTwitsTrendingWidget.getJSONPCallback",function(b){a.display(b);a.updateTimer&&clearTimeout(a.updateTimer);a.updateTimer=setTimeout(function(){a.update()},6E4)})};StockTwitsTrendingWidget.display=function(a){if(!a.trends)return false;var b=Math.min(this.trendOpts.limit,a.trends.length),c=document.getElementById("stTrendingModuleContent");
c.innerHTML="";for(var d=0;d<b;d++){var e=a.trends[d].symbol,g=this.trendOpts.trendingStream=="hourly"?a.trends[d].hourly_trend_sparkline_url:a.trends[d].daily_trend_sparkline_url,f=document.createElement("div");f.className="stTrendingStatus";f.innerHTML="<a class='stTicker' href='http://stocktwits.com/symbol/"+e+this.urlTag+"'>$"+e+"</a><a href='http://stocktwits.com/symbol/"+e+this.urlTag+"'><img width='150' height='25' src='"+g+"' alt='Why is this Trending?' title='Why is this Trending?' />";c.appendChild(f)}return true};
StockTwitsTrendingWidget.ie=/MSIE\s([^;]*)/.test(navigator.userAgent);StockTwitsTrendingWidget.urlTag="?utm_medium=widget&utm_campaign=trendingwidget&utm_source="+document.domain})();

