/**
* AbnormalReturns - http://abnormalreturns.com
* Copyright (c) 2010 StockTwits
* Author: Chris Corriveau (chris@stocktwits.com), Dustin Schneider (dustin@stocktwits.com)
*
* Version: 1.0
* Get widget at: http://abnormalreturns.com/widget
* Get more at: http://stocktwits.com/goodies
*/
var AbnormalReturnsWidget={}; (function(){AbnormalReturnsWidget.widgetHelpersUrl="http://abnormalreturns.com/addon/widget/1";AbnormalReturnsWidget.load=function(a){this.arOpts=a=a||{};this.streamUrl="http://abnormalreturns.com/links.json";this.streamTitle="Abnormal Returns Now";if(this.arOpts.title)this.streamTitle=this.arOpts.title;a.display_messages=a.display_messages||10;a.style=a.style||{};this.show();return this};AbnormalReturnsWidget.show=function(){document.write("<!-- begin Abnormal Returns widget --\><div id='AbnormalReturns_wrapper'><div id='arModuleHeader' class='arModuleHeader'><div id='arModuleTitle' class='arTitle'>"+this.streamTitle+ "</div></div><div id='arModuleContent' class='arModuleContent'></div><div align='center' id='arModuleFooter' class='arModuleFooter'><a href='http://stocktwits.com/"+this.urlTag+"' target='_blank'><img src='"+this.widgetHelpersUrl+"/stocktwits-logo.png' class='arLogo' /></a><a href='http://abnormalreturns.com/"+this.urlTag+"' target='_blank' class='arTagline'>Links in Real-Time</a></div></div><!-- end Abnormal Returns widget --\>");this.injectCSS();var a=this.arOpts.style,b=document.getElementById("AbnormalReturns_wrapper"), c=document.getElementById("arModuleHeader"),e=document.getElementById("arModuleContent"),d=document.getElementById("arModuleFooter");if(a.background_color){b.style.backgroundColor=a.background_color;e.style.backgroundColor=a.background_color}if(a.border)b.style.border=a.border;if(a.width)b.style.width=a.width;if(a.height)e.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)d.style.backgroundColor=a.footer_color;if(a.overflow)e.style.overflow=a.overflow;b="";if(a.link_color)b+="#AbnormalReturns_wrapper a { color: "+a.link_color+";} ";if(a.time_color)b+="div.arStatus a.arTime { color: "+a.time_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()};AbnormalReturnsWidget.injectCSS=function(){var a=document.createElement("link");a.setAttribute("rel","stylesheet");a.setAttribute("type","text/css");a.setAttribute("href",this.widgetHelpersUrl+"/abnormalreturns.css");document.getElementsByTagName("head")[0].appendChild(a)};AbnormalReturnsWidget.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};AbnormalReturnsWidget.getJSONPCallback=function(a){this._JSONPCallback.call(this,a);this._JSONPCallback=undefined;try{this._JSONPScript.parentNode.removeChild(this._JSONPScript)}catch(b){}};AbnormalReturnsWidget.update=function(){var a=this;this.getJSONP(this.streamUrl+"?callback=AbnormalReturnsWidget.getJSONPCallback",function(b){a.display(b);a.updateTimer&&clearTimeout(a.updateTimer);a.updateTimer=setTimeout(function(){a.update()},6E4)})};AbnormalReturnsWidget.display=function(a){if(!a.links)return false; var b=Math.min(this.arOpts.display_messages,a.links.length),c=document.getElementById("arModuleContent");c.innerHTML="";for(var e=0;e<b;e++){var d=a.links[e].link,g=this.messageTime(this.date(d.updated_at)),h=d.title,i="&"+this.urlTag.substring(1),f="http://abnormalreturns.com/links/index?date="+this.linkDate(this.date(d.updated_at));f+=i+"#"+d.id;d=document.createElement("div");d.className="arStatus";d.innerHTML="<div class='arLink'><a href='"+f+"' target='_blank'>"+h+"</a><br /><span class='arTime'>"+ g+"</span>";c.appendChild(d)}return true};AbnormalReturnsWidget.parseISO8601=function(a){var b=a.split("T");a=b[0].split("-");b=b[1].split("Z")[0].split(":");var c=b[2].split("."),e=Number(b[0]),d=new Date;d.setUTCFullYear(Number(a[0]));d.setUTCMonth(Number(a[1])-1);d.setUTCDate(Number(a[2]));d.setUTCHours(Number(e));d.setUTCMinutes(Number(b[1]));d.setUTCSeconds(Number(c[0]));c[1]&&d.setUTCMilliseconds(Number(c[1]));return d};AbnormalReturnsWidget.date=function(a){var b=new Date(a);if(isNaN(b))b= this.parseISO8601(a);return b};AbnormalReturnsWidget.messageTime=function(a){var b=(a.getHours()+12)%12;if(b===0)b=12;var c=["January","February","March","April","May","June","July","August","September","October","November","December"][a.getMonth()],e=a.getMinutes()>9?a.getMinutes():"0"+a.getMinutes(),d=a.getHours()<12?"am":"pm";return c+" "+a.getDate()+", "+b+":"+e+" "+d};AbnormalReturnsWidget.linkDate=function(a){var b=a.getMonth()>9?a.getMonth()+1:"0"+(a.getMonth()+1),c=a.getDate();a=a.getFullYear(); return b+"/"+c+"/"+a};AbnormalReturnsWidget.ie=function(){return/MSIE\s([^;]*)/.test(navigator.userAgent)}();AbnormalReturnsWidget.capitalize=function(a){return a.charAt(0).toUpperCase()+a.slice(1)};AbnormalReturnsWidget.urlTag="?utm_medium=widget&utm_campaign=widget&utm_source="+document.domain})();