
function RTTradeStatsDashboardManager(caller,callback,pageSize,appId,contentCaller)
{this.callback=callback;this.contentCaller=contentCaller;this.contents=new Array();this.caller=caller;this.appId=appId;pageSize=(undefined==pageSize)?PAGE_SIZE_SUBLISTING:pageSize;var viewer=new RTTradeStatsSnapshotDOM(true);this.mmHandler=new TopMarketMakersSimple(caller,viewer,undefined,this,this.PAGE_SIZE_BIG,appId);this.quotedHandler=new TopQuotedSimple(caller,viewer,undefined,this,pageSize,appId);this.wombatHandler=new TopWombatTradesSimple(caller,viewer,undefined,this,pageSize,appId);this.anchorList=new FancyAnchorList();this.tabberFull=new Tabbers(this.createTabberOptions('doTabFull',this.TAB_CAPTIONS,this.TAB_VALUES));this.tabberMM=new Tabbers(this.createTabberOptions('doTabMM',this.TAB_CAPTIONS_MM,this.TAB_VALUES_MM));this.CSS_TOP=this.CSS_MAIN+'Top';this.CSS_BOTTOM=this.CSS_MAIN+'Bottom';this.CSS_LEFT=this.CSS_MAIN+'Left';this.CSS_RIGHT=this.CSS_MAIN+'Right';this.CSS_MORE=this.CSS_MAIN+'More';this.CSS_LESS=this.CSS_MAIN+'Less';}
RTTradeStatsDashboardManager.prototype.PAGE_SIZE_BIG=PAGE_SIZE_WORKLIST;RTTradeStatsDashboardManager.prototype.CMS_URI='/realTimeTradeStats/notes/';RTTradeStatsDashboardManager.prototype.CSS_MAIN='dashBoard';RTTradeStatsDashboardManager.prototype.CAPTION_MORE='More >>';RTTradeStatsDashboardManager.prototype.CAPTION_LESS='<< Back to Dashboard';RTTradeStatsDashboardManager.prototype.TAB_CAPTIONS=['All OTC','OTCQX','Pink Quote/OTCBB','OTCBB Only','Pink Sheets','Grey Market'];RTTradeStatsDashboardManager.prototype.TAB_VALUES=[{id:'ALL'},{id:'QX'},{id:'DQ'},{id:'BB'},{id:'PS'},{id:'GM',hideTopQuoted:true}];RTTradeStatsDashboardManager.prototype.TAB_CAPTIONS_MM=['All OTC','OTCQX','Pink Quote/OTCBB','Pink Sheets'];RTTradeStatsDashboardManager.prototype.TAB_VALUES_MM=[{id:'ALL'},{id:'QX'},{id:'DQ'},{id:'PS'}];RTTradeStatsDashboardManager.prototype.TOP_TRADE_TITLES=['$ Volume','Share Volume','# Trades'];RTTradeStatsDashboardManager.prototype.TOP_TRADE_CALLS=['doDollarVolume','doVolume','doTrades'];RTTradeStatsDashboardManager.prototype.MOVERS_TITLES=['Over $1','Over $0.05','All'];RTTradeStatsDashboardManager.prototype.GAINERS_CALLS=['doGainersOverDollar','doGainersOver5Cents','doAllGainers'];RTTradeStatsDashboardManager.prototype.LOSERS_CALLS=['doLosersOverDollar','doLosersOver5Cents','doAllLosers'];RTTradeStatsDashboardManager.prototype.TOP_QUOTED_CALLS=['doQuotedOverDollar','doQuotedOver5Cents','doAllQuoted'];RTTradeStatsDashboardManager.prototype.init=function(body){this.initFull(body);}
RTTradeStatsDashboardManager.prototype.initFull=function(body,startTab)
{if(undefined!=startTab)
this.tabberFull.defaultTab=startTab;this.tabberFull.run(body);}
RTTradeStatsDashboardManager.prototype.initMM=function(body,startTab)
{if(undefined!=startTab)
this.tabberMM.defaultTab=startTab;this.tabberMM.run(body);}
RTTradeStatsDashboardManager.prototype.doTabFull=function(value,body)
{body.innerHTML='';var elem=value.dashBody=document.createElement('div');elem.className='widgetPackage';var tradeTotals=document.createElement('div');tradeTotals.className='topInfo';value.tradeAggregateBody=tradeTotals;elem.appendChild(tradeTotals);var notes=document.createElement('div');notes.className='rtNotes';elem.appendChild(notes);var uri=this.CMS_URI+value.id;var contents=this.contents[uri];if(undefined!=contents)
this.displayContents(notes,contents);else
this.contentCaller.getPageText(undefined,uri,new RTTradeStatsDashboardManagerContentHandler(this,notes,uri));elem.appendChild(this.generateFull(value));body.appendChild(elem);body.appendChild(elem=value.detailBody=document.createElement('div'));elem.className='widgetPackage';elem.style.display='none';body.appendChild(elem);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);if(undefined!=value.quotedBody)
this.quotedHandler.doFilter(value.quotedBody,this.pageSize,1,value.id);this.wombatHandler.doLosers(value.losersBody,this.pageSize,1,value.id);}
RTTradeStatsDashboardManager.prototype.doTabMM=function(value,body)
{var div,elem=value.marketMakerBody=document.createElement('div');elem.className='bodyContainer';body.innerHTML='';body.appendChild(this.genAnchors(this.TOP_TRADE_TITLES,this.TOP_TRADE_CALLS,elem,this.mmHandler,undefined,value.id));body.appendChild(elem);this.mmHandler.doDollarVolume(value.marketMakerBody,this.PAGE_SIZE_BIG,value.id);}
RTTradeStatsDashboardManager.prototype.generateFull=function(value)
{var output=document.createElement('table');output.className=this.CSS_MAIN;output.cellSpacing=0;var row=output.insertRow(0);row.className=this.CSS_TOP;value.volumeBody=this.genCell(row,0,'Most Active',this.CSS_LEFT,this.TOP_TRADE_TITLES,this.TOP_TRADE_CALLS,this.wombatHandler,value).myBody;value.gainersBody=this.genCell(row,1,'Advancers',this.CSS_RIGHT,this.MOVERS_TITLES,this.GAINERS_CALLS,this.wombatHandler,value).myBody;row=output.insertRow(1);row.className=this.CSS_BOTTOM;if(value.hideTopQuoted)
{var elem,cell=row.insertCell(0);cell.className=this.CSS_LEFT;cell.appendChild(elem=document.createElement('h2'));elem.appendChild(document.createTextNode('Most Quote Updates'));cell.appendChild(elem=document.createElement('div'));elem.innerHTML='Grey Market securities are securities without an active Market Maker quote within Pink Sheets\' Electronic Quotation System.';}
else
value.quotedBody=this.genCell(row,0,'Most Quote Updates',this.CSS_LEFT,this.MOVERS_TITLES,this.TOP_QUOTED_CALLS,this.quotedHandler,value).myBody;value.losersBody=this.genCell(row,1,'Decliners',this.CSS_RIGHT,this.MOVERS_TITLES,this.LOSERS_CALLS,this.wombatHandler,value).myBody;return output;}
RTTradeStatsDashboardManager.prototype.genCell=function(row,index,title,className,captions,calls,widget,value)
{var output=row.insertCell(index);output.className=className;var elem=document.createElement('h2');elem.appendChild(document.createTextNode(title));output.appendChild(elem);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.appendChild(document.createTextNode(this.CAPTION_MORE));elem=output.myBody=document.createElement('div');elem.className='bodyContainer';output.appendChild(this.genAnchors(captions,calls,elem,widget,undefined,value.id,a));output.appendChild(elem);elem=document.createElement('div');elem.className=this.CSS_MORE;elem.appendChild(a);output.appendChild(elem);return output;}
RTTradeStatsDashboardManager.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;}
RTTradeStatsDashboardManager.prototype.handlePostLoad=function(value)
{if((undefined!=this.callback)&&(undefined!=this.callback.handlePostLoad))
this.callback.handlePostLoad(value);}
RTTradeStatsDashboardManager.prototype.handleTabbed=function(value)
{if((undefined!=this.callback)&&(undefined!=this.callback.handleTabbed))
this.callback.handleTabbed(value.id);}
RTTradeStatsDashboardManager.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;}
RTTradeStatsDashboardManager.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;}
RTTradeStatsDashboardManager.prototype.handleLess=function(ev)
{var value=this.myValue;value.detailBody.style.display='none';value.dashBody.style.display='block';return false;}
RTTradeStatsDashboardManager.prototype.gotoQuote=function(symbol,securityId)
{if((undefined!=this.callback)&&(undefined!=this.callback.gotoQuote))
this.callback.gotoQuote(symbol,securityId);}
RTTradeStatsDashboardManager.prototype.createTabberOptions=function(method,captions,values)
{var me=this;return{ids:undefined,defaultTab:0,titles:captions,values:values,callback:me,tabMethod:method,onClick:function(args)
{var value=this.values[args.index];this.callback.handleTabbed(value);if(!args.tab.isEmpty)
return true;try{this.callback[this.tabMethod](value,args.tab.body);}
catch(error){window.alert(error);return false;}
args.tab.isEmpty=false;return true;},onLoad:function(args){this.onClick(args);}};}
RTTradeStatsDashboardManager.prototype.doDollarVolume=function(widget,body,pageSize,tierGroupId){widget.doDollarVolume(body,pageSize,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doVolume=function(widget,body,pageSize,tierGroupId){widget.doVolume(body,pageSize,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doTrades=function(widget,body,pageSize,tierGroupId){widget.doTrades(body,pageSize,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doGainersOverDollar=function(widget,body,pageSize,tierGroupId){widget.doGainers(body,pageSize,1,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doGainersOver5Cents=function(widget,body,pageSize,tierGroupId){widget.doGainers(body,pageSize,.05,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doAllGainers=function(widget,body,pageSize,tierGroupId){widget.doGainers(body,pageSize,undefined,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doLosersOverDollar=function(widget,body,pageSize,tierGroupId){widget.doLosers(body,pageSize,1,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doLosersOver5Cents=function(widget,body,pageSize,tierGroupId){widget.doLosers(body,pageSize,.05,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doAllLosers=function(widget,body,pageSize,tierGroupId){widget.doLosers(body,pageSize,undefined,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doQuotedOverDollar=function(widget,body,pageSize,tierGroupId){widget.doFilter(body,pageSize,1,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doQuotedOver5Cents=function(widget,body,pageSize,tierGroupId){widget.doFilter(body,pageSize,.05,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doAllQuoted=function(widget,body,pageSize,tierGroupId){widget.doFilter(body,pageSize,undefined,tierGroupId);}
RTTradeStatsDashboardManager.prototype.doTradeAggregates=function(body,tierGroupId){this.caller.getAggregateWombatTradesForTierGroup(tierGroupId,new AjaxDataHandler(this,{'id':tierGroupId,'body':body}))}
RTTradeStatsDashboardManager.prototype.doValue=function(value){var criteria=value.criteria;criteria.body.innerHTML='';criteria.body.appendChild(new TradeAggregateDOM().generate(value));}
RTTradeStatsDashboardManager.prototype.displayContents=function(body,item)
{if('X'==item)
body.style.display='none';else
{body.innerHTML=item.contents;body.style.display='block';}}
function RTTradeStatsDashboardManagerContentHandler(callback,body,name)
{this.callback=callback;this.body=body;this.name=name;}
RTTradeStatsDashboardManagerContentHandler.prototype.handleRequestData=function(value)
{value=((undefined==value)||(undefined==value.contents))?'X':value;this.callback.contents[this.name]=value;this.callback.displayContents(this.body,value);}