
function ListQXSecuritySimple(caller,viewer,body,pageSize,iqCaller,callback)
{this.caller=caller;this.viewer=viewer;this.body=body;this.pageSize=pageSize;this.iqCaller=iqCaller;this.callback=callback;this.criteria=undefined;}
ListQXSecuritySimple.prototype=new WorklistSimple();ListQXSecuritySimple.prototype.doSearch=function(body)
{this.run(new ListQXSecurityCriteria(),body);}
ListQXSecuritySimple.prototype.doLatest=function(pageSize,body)
{this.run(new ListQXSecurityCriteria(undefined,pageSize,FIELD_START_DATE,FIELD_DESCENDING),body);}
ListQXSecuritySimple.prototype.makeCall=function(criteria,dataHandler)
{this.caller.getQXSecurities(criteria,dataHandler);}
ListQXSecuritySimple.prototype.decorateTradeInfo=function(table)
{if(!this.tradeDecorater)
this.tradeDecorater=new DecorateTradeInfo(new OtcIQCalls());this.tradeDecorater.run({tagName:'tr'},table);}
ListQXSecuritySimple.prototype.gotoQuote=function(ev){this.myCallback.callback.gotoQXQuote(this.myRecord.symbol);return false;}
function ListQXSecurityCriteria(page,pageSize,sortOn,sortDir)
{this.page=page;this.pageSize=pageSize;this.sortOn=sortOn;this.sortDir=sortDir;}

function ListQXSecuritySnapshot(imagePath)
{this.imagePath=imagePath;}
ListQXSecuritySnapshot.prototype=new WorklistDOM();ListQXSecuritySnapshot.prototype.generate=function(value,callback)
{var noRecordsFlag=((undefined==value.records)||(0==value.records.length));var output=document.createElement('div');var records=value.records;if((undefined==records)&&(0==records.length))
{output=document.createElement('span');output.appendChild(document.createTextNode('No '+CAPTION_QX+' '+value.plural+' exist.'));return output;}
var table=document.createElement('table');table.cellSpacing=0;for(var i=0;i<value.records.length;i++)
{var record=value.records[i];var row=table.insertRow(i);var _cell=0;var cell=row.insertCell(_cell++);cell.appendChild(this.createSymbolAnchor(record,callback));this.createDetailCell(row,_cell++,record.companyName);this.createDetailCell(row,_cell++,toDisplayable(record.region));}
output.appendChild(table);return output;}

function TradeStatsWorklistSimple(caller,viewer,body,callback,pageSize)
{this.caller=caller;this.viewer=viewer;this.body=body;this.callback=callback;this.pageSize=pageSize;}
TradeStatsWorklistSimple.prototype=new WorklistSimple();TradeStatsWorklistSimple.prototype.doTrades=function(body,pageSize,tierGroupId)
{this.doFilter(new TradeStatFilter(pageSize,'tradeCount',undefined,tierGroupId),body);}
TradeStatsWorklistSimple.prototype.doVolume=function(body,pageSize,tierGroupId)
{this.doFilter(new TradeStatFilter(pageSize,FIELD_VOLUME,undefined,tierGroupId),body);}
TradeStatsWorklistSimple.prototype.doDollarVolume=function(body,pageSize,tierGroupId)
{this.doFilter(new TradeStatFilter(pageSize,FIELD_DOLLAR_VOLUME,undefined,tierGroupId),body);}
TradeStatsWorklistSimple.prototype.doGainers=function(body,pageSize,priceMin,tierGroupId)
{this.doFilter(new TradeStatFilter(pageSize,FIELD_GAIN,priceMin,tierGroupId),body);}
TradeStatsWorklistSimple.prototype.doLosers=function(body,pageSize,priceMin,tierGroupId)
{this.doFilter(new TradeStatFilter(pageSize,FIELD_LOSS,priceMin,tierGroupId),body);}
TradeStatsWorklistSimple.prototype.doMostUpdated=function(body,pageSize,priceMin,tierGroupId)
{this.doFilter(new TradeStatFilter(pageSize,'updateCount',priceMin,tierGroupId),body);}
TradeStatsWorklistSimple.prototype.doFilter=function(filter,body)
{this.run(filter,body);}
TradeStatsWorklistSimple.prototype.makeCall=function(criteria,dataHandler)
{this.caller.getTradeStatsWorklist(criteria,dataHandler);}
TradeStatsWorklistSimple.prototype.gotoQuote=function()
{var record=this.myRecord;this.myCallback.callback.gotoQuote(record.symbol,record.securityId);return false;}

function TradeStatsWorklistDOM(paging)
{this.paging=(undefined==paging)?false:paging;}
TradeStatsWorklistDOM.prototype=new WorklistDOM();TradeStatsWorklistDOM.prototype.CAPTIONS=['Price','Pct Chg','$ Volume','Share Volume','# Trades'];TradeStatsWorklistDOM.prototype.generate=function(value,callback)
{var output=document.createElement('div');output.className='widgetPackage listingContainer';var records=value.records;if((undefined==records)||(0==records.length))
{var elem=document.createElement('div');elem.className='tabNoData';elem.appendChild(document.createTextNode('No data found.'));output.appendChild(elem);return output;}
var criteria=value.criteria;var table=document.createElement('table');table.className='listing';table.cellSpacing=0;var cellIndex=0;var row=table.insertRow(0);row.className='listingHeader';this.createHeaderCell(row,cellIndex++,'Symbol');if(criteria.sortOn=='updateCount')
this.toRight(this.createHeaderCell(row,cellIndex++,'Updates'));this.toRight(this.createHeaderCell(row,cellIndex++,this.CAPTIONS[0]));this.toRight(this.createHeaderCell(row,cellIndex++,this.CAPTIONS[1]));this.toRight(this.createHeaderCell(row,cellIndex++,this.CAPTIONS[2]));this.toRight(this.createHeaderCell(row,cellIndex++,this.CAPTIONS[3]));this.toRight(this.createHeaderCell(row,cellIndex++,this.CAPTIONS[4]));for(var i=0;i<records.length;i++)
{cellIndex=0;row=table.insertRow(i+1);row.className=alternateCssParentListingClasses(i);var record=records[i];var td=row.insertCell(cellIndex++);td.className=row.className;var a=document.createElement('a');a.href='javascript:void(null);';a.appendChild(document.createTextNode(record.symbol));a.onclick=callback.gotoQuote;a.myRecord=record;a.myCallback=callback;td.appendChild(a);if(criteria.sortOn=='updateCount')
this.toRight(this.createDetailCell(row,cellIndex++,Formatter.toVolume(record.updateCount)));if(0==record.price)
{this.toRight(this.createDetailCell(row,cellIndex++,CAPTION_NA));this.toRight(this.createDetailCell(row,cellIndex++,CAPTION_NA));}
else
{var isPositive=(0<record.pricePct);var color=isPositive?COLOR_POSITIVE:COLOR_NEGATIVE;var sign=isPositive?'+':'';this.toRight(this.createDetailCell(row,cellIndex++,Formatter.toPrice(record.price)));this.enhancePriceCell(this.createDetailCell(row,cellIndex++,sign+Formatter.toPercentX(record.pricePct)),color);}
this.toRight(this.createDetailCell(row,cellIndex++,Formatter.toVolume(record.dollarVolume)));this.toRight(this.createDetailCell(row,cellIndex++,Formatter.toVolume(record.volume)));this.toRight(this.createDetailCell(row,cellIndex++,this.toDisplayable(Formatter.toVolume(record.tradeCount))));}
output.appendChild(table);if(this.paging||(PAGE_SIZE_SUBLISTING<value.pageSize))
output.appendChild((new PagingLinksDOM()).generate(value,callback));if(undefined==value.footnotes)
return output;output.appendChild(document.createElement('hr'));var footnote=document.createElement('div');footnote.className='footnote';for(var i=0;i<value.footnotes.length;i++)
{if(0<i)
footnote.appendChild(document.createElement('br'));var sup=document.createElement('sup');sup.appendChild(document.createTextNode((i+1)));footnote.appendChild(sup);footnote.appendChild(document.createTextNode(value.footnotes[i]));}
output.appendChild(footnote);return output;}
TradeStatsWorklistDOM.prototype.toDisplayable=function(value)
{if(undefined==value)
return CAPTION_NA;return value;}
TradeStatsWorklistDOM.prototype.createHeaderCell=function(row,index,caption)
{var output=row.insertCell(index);output.className='listingHeader';output.style.whiteSpace='nowrap';output.appendChild(document.createTextNode(caption));return output;}
TradeStatsWorklistDOM.prototype.createDetailCell=function(row,index,value)
{var output=row.insertCell(index);output.className=row.className;output.innerHTML=value;return output;}
TradeStatsWorklistDOM.prototype.toRight=function(elem)
{elem.style.textAlign='right';return elem;}
TradeStatsWorklistDOM.prototype.enhancePriceCell=function(cell,color)
{this.toRight(cell).style.color=color;}

function TierSecurityStatsWorklistSimple(caller,viewer,body,callback,pageSize)
{this.caller=caller;this.viewer=viewer;this.body=body;this.callback=callback;this.pageSize=pageSize;}
TierSecurityStatsWorklistSimple.prototype=new WorklistSimple();TierSecurityStatsWorklistSimple.prototype.init=function(body)
{this.run({},body);}
TierSecurityStatsWorklistSimple.prototype.makeCall=function(criteria,dataHandler)
{this.caller.getTierSecurityStatsWorklist(dataHandler);}

function TierSecurityStatsWorklistDOM(){}
TierSecurityStatsWorklistDOM.prototype=new WorklistDOM();TierSecurityStatsWorklistDOM.prototype.generate=function(value,callback)
{var records=value.records;if((undefined==records)||(0==records.length))
this.createNoDataFound();var row,rows=0,table=document.createElement('table');table.className=this.CSS_TABLE;row=table.insertRow(rows++);row.className=this.CSS_HEADER;this.createHeaderCell(row,0,'');this.createHeaderCell(row,1,'Securities').style.textAlign='right';this.createHeaderCell(row,2,'$ Volume').style.textAlign='right';this.createHeaderCell(row,3,'Share Volume').style.textAlign='right';for(var i=0;i<records.length;i++)
{var record=records[i];row=table.insertRow(rows++);row.className=this.getRowCss(i);this.createDetailCell(row,0,record.tierName);this.createDetailCell(row,1,Formatter.toVolume(record.count)).style.textAlign='right';this.createDetailCell(row,2,Formatter.toVolume(record.sumDollarVolume)).style.textAlign='right';this.createDetailCell(row,3,Formatter.toVolume(record.sumVolume)).style.textAlign='right';}
row=table.insertRow(rows++);var cell=row.insertCell(0);cell.innerHTML='&nbsp;';cell.colspan=4;row=table.insertRow(rows++);this.createTotalCell(row,0,'Totals');this.createTotalCellX(row,1,Formatter.toVolume(value.count));this.createTotalCellX(row,2,Formatter.toVolume(value.sumDollarVolume));this.createTotalCellX(row,3,Formatter.toVolume(value.sumVolume));var output=document.createElement('div');output.className='widgetPackage';output.appendChild(table);output.appendChild(document.createElement('br'));output.appendChild(document.createTextNode('As of '+Formatter.toFullDate(value.statsDate)));return output;}
TierSecurityStatsWorklistDOM.prototype.createTotalCell=function(row,cell,value)
{var elem,output=row.insertCell(cell);output.appendChild(elem=document.createElement('b'));elem.innerHTML=value;return output;}
TierSecurityStatsWorklistDOM.prototype.createTotalCellX=function(row,cell,value)
{var output=this.createTotalCell(row,cell,value);output.style.textAlign='right';output.style.paddingLeft='8px';return output;}
