
function RTDashboardHandler(caller,callback,pageSize,appId,contentCaller)
{this.callback=callback;this.caller=caller;this.appId=appId;pageSize=(undefined==pageSize)?PAGE_SIZE_SUBLISTING:pageSize;var viewer=new RTTradeStatsSnapshotDOM(true);viewer.CAPTIONS=['Price','% Chg','$ Vol.','Share Vol.','Trades'];this.quotedHandler=new TopQuotedSimple(caller,viewer,undefined,this,pageSize,appId);this.wombatHandler=new TopWombatTradesSimple(caller,viewer,undefined,this,pageSize,appId);this.anchorList=new FancyAnchorList();}
RTDashboardHandler.prototype.PAGE_SIZE_BIG=PAGE_SIZE_WORKLIST;RTDashboardHandler.prototype.CMS_URI='/realTimeTradeStats/notes/';RTDashboardHandler.prototype.CSS_MAIN='dashBoard';RTDashboardHandler.prototype.CSS_MORE='more';RTDashboardHandler.prototype.CSS_LESS='less';RTDashboardHandler.prototype.CAPTION_MORE='More >>';RTDashboardHandler.prototype.CAPTION_LESS='<< Back to Dashboard';RTDashboardHandler.prototype.TOP_TRADE_TITLES=['$ Volume','Share Volume','# Trades'];RTDashboardHandler.prototype.TOP_TRADE_CALLS=['doDollarVolume','doVolume','doTrades'];RTDashboardHandler.prototype.MOVERS_TITLES=['Over $1','Over $0.05','All'];RTDashboardHandler.prototype.GAINERS_CALLS=['doGainersOverDollar','doGainersOver5Cents','doAllGainers'];RTDashboardHandler.prototype.LOSERS_CALLS=['doLosersOverDollar','doLosersOver5Cents','doAllLosers'];RTDashboardHandler.prototype.TOP_QUOTED_CALLS=['doQuotedOverDollar','doQuotedOver5Cents','doAllQuoted'];RTDashboardHandler.prototype.TIER_ID='QX';RTDashboardHandler.prototype.init=function(body)
{body.innerHTML='';value=new Object();value.id=this.TIER_ID;var elem=document.createElement('div');elem.className='summary msSummary';value.tradeAggregateBody=elem;var div=value.dashBody=document.createElement('div');div.appendChild(elem);body.appendChild(div);div.appendChild(elem=this.genCell('Most Active',this.CSS_LEFT,this.TOP_TRADE_TITLES,this.TOP_TRADE_CALLS,this.wombatHandler,value));value.volumeBody=elem.myBody;div.appendChild(elem=this.genCell('Advancers',this.CSS_RIGHT,this.MOVERS_TITLES,this.GAINERS_CALLS,this.wombatHandler,value));value.gainersBody=elem.myBody;div.appendChild(elem=this.genCell('Most Quote Updates',this.CSS_LEFT,this.MOVERS_TITLES,this.TOP_QUOTED_CALLS,this.quotedHandler,value));value.quotedBody=elem.myBody;div.appendChild(elem=this.genCell('Decliners',this.CSS_RIGHT,this.MOVERS_TITLES,this.LOSERS_CALLS,this.wombatHandler,value));value.losersBody=elem.myBody;var div=value.detailBody=document.createElement('div');div.style.display='none';body.appendChild(div);this.doTradeAggregates(value.tradeAggregateBody,value.id);this.wombatHandler.doDollarVolume(value.volumeBody,this.pageSize,value.id);this.wombatHandler.doGainers(value.gainersBody,this.pageSize,1,value.id);this.quotedHandler.doFilter(value.quotedBody,this.pageSize,1,value.id);this.wombatHandler.doLosers(value.losersBody,this.pageSize,1,value.id);}
RTDashboardHandler.prototype.genCell=function(title,className,captions,calls,widget,value)
{var output=document.createElement('div');output.className='ms box';var elem=document.createElement('h3');elem.innerHTML=title;output.appendChild(elem);elem=document.createElement('div');elem.className='content';output.appendChild(elem);output.myBody=document.createElement('div');output.appendChild(output.myBody);elem.appendChild(this.genAnchors(captions,calls,output.myBody,widget,undefined,value.id));elem=document.createElement('div');elem.className=this.CSS_MORE;var a=document.createElement('a');a.href='javascript:void(null)';a.myCallback=this;a.myValue=value;a.myWidget=widget;a.myCaptions=captions;a.myCalls=calls;a.myCall=calls[0];a.myTitle=title;a.onclick=this.handleMore;a.innerHTML='More <img src="/otcqx/images/icon-arrow-more.png"/>';elem.appendChild(a);output.appendChild(elem);return output;}
RTDashboardHandler.prototype.genAnchors=function(captions,calls,body,widget,pageSize,tierGroupId,moreAnchor,call)
{if(undefined==call)
call=calls[0];var listItems={ids:calls,values:captions};var criteria=new AnchorListCriteria(listItems,call,this);criteria.myWidget=widget;criteria.myBody=body;criteria.myPageSize=pageSize;criteria.myTierGroupId=tierGroupId;criteria.moreAnchor=moreAnchor;var output=document.createElement('div');output.className='anchorContainer';this.anchorList.run(criteria,output);return output;}
RTDashboardHandler.prototype.handlePostLoad=function(value)
{if((undefined!=this.callback)&&(undefined!=this.callback.handlePostLoad))
this.callback.handlePostLoad(value);}
RTDashboardHandler.prototype.handleAnchorSelect=function(id,caption,criteria)
{this[id](criteria.myWidget,criteria.myBody,criteria.myPageSize,criteria.myTierGroupId);this.lastAction=id;this.lastCriteria=criteria;if(undefined!=criteria.moreAnchor)
criteria.moreAnchor.myCall=id;}
RTDashboardHandler.prototype.handleMore=function(ev)
{var me=this.myCallback;var value=this.myValue;var body=value.detailBody;var call=this.myCall;var calls=this.myCalls;var widget=this.myWidget;body.innerHTML='';var elem=document.createElement('div');elem.className=me.CSS_LESS;var a=document.createElement('a');a.href='javascript:void(null);';a.myCallback=me;a.myValue=value;a.appendChild(document.createTextNode(me.CAPTION_LESS));a.onclick=me.handleLess;elem.appendChild(a);body.appendChild(elem);body.appendChild(elem=document.createElement('h2'));elem.innerHTML=this.myTitle;elem=document.createElement('div');elem.className='bodyContainer';body.appendChild(me.genAnchors(this.myCaptions,calls,elem,widget,me.PAGE_SIZE_BIG,value.id,undefined,call));me[call](widget,elem,me.PAGE_SIZE_BIG,value.id);body.appendChild(elem);value.dashBody.style.display='none';body.style.display='block';return false;}
RTDashboardHandler.prototype.handleLess=function(ev)
{var value=this.myValue;value.detailBody.style.display='none';value.dashBody.style.display='block';return false;}
RTDashboardHandler.prototype.gotoQuote=function(symbol,securityId)
{appNav.gotoQuote(symbol);}
RTDashboardHandler.prototype.doDollarVolume=function(widget,body,pageSize,tierGroupId){widget.doDollarVolume(body,pageSize,tierGroupId);}
RTDashboardHandler.prototype.doVolume=function(widget,body,pageSize,tierGroupId){widget.doVolume(body,pageSize,tierGroupId);}
RTDashboardHandler.prototype.doTrades=function(widget,body,pageSize,tierGroupId){widget.doTrades(body,pageSize,tierGroupId);}
RTDashboardHandler.prototype.doGainersOverDollar=function(widget,body,pageSize,tierGroupId){widget.doGainers(body,pageSize,1,tierGroupId);}
RTDashboardHandler.prototype.doGainersOver5Cents=function(widget,body,pageSize,tierGroupId){widget.doGainers(body,pageSize,.05,tierGroupId);}
RTDashboardHandler.prototype.doAllGainers=function(widget,body,pageSize,tierGroupId){widget.doGainers(body,pageSize,undefined,tierGroupId);}
RTDashboardHandler.prototype.doLosersOverDollar=function(widget,body,pageSize,tierGroupId){widget.doLosers(body,pageSize,1,tierGroupId);}
RTDashboardHandler.prototype.doLosersOver5Cents=function(widget,body,pageSize,tierGroupId){widget.doLosers(body,pageSize,.05,tierGroupId);}
RTDashboardHandler.prototype.doAllLosers=function(widget,body,pageSize,tierGroupId){widget.doLosers(body,pageSize,undefined,tierGroupId);}
RTDashboardHandler.prototype.doQuotedOverDollar=function(widget,body,pageSize,tierGroupId){widget.doFilter(body,pageSize,1,tierGroupId);}
RTDashboardHandler.prototype.doQuotedOver5Cents=function(widget,body,pageSize,tierGroupId){widget.doFilter(body,pageSize,.05,tierGroupId);}
RTDashboardHandler.prototype.doAllQuoted=function(widget,body,pageSize,tierGroupId){widget.doFilter(body,pageSize,undefined,tierGroupId);}
RTDashboardHandler.prototype.doTradeAggregates=function(body,tierGroupId){this.caller.getAggregateWombatTradesForTierGroup(tierGroupId,new AjaxDataHandler(this,{'id':tierGroupId,'body':body}))}
RTDashboardHandler.prototype.doValue=function(value){var criteria=value.criteria;criteria.body.innerHTML='';criteria.body.appendChild(new TradeAggregateDOM().generate(value));}
RTDashboardHandler.prototype.handlePostLoad=function(value)
{document.getElementById('currentDate').innerHTML=(value.latest==undefined)?'':Formatter.toDateTime2(value.latest.calcTime);}