
function paintpage(tab,symbol){var body=document.getElementById('quote');pageHistory.start();var handler=QuoteHandler.getInstance((tab==undefined)?0:tab,pageHistory);handler.doSecurity(pinkSecurity,body);}
function QuoteHandler(edgarCaller,edgarPager,otciqCaller,otciqPager,forumsCaller,forumsImagesPath,commonCaller,body,pageSize,contentCaller,tabValue,pageHistory)
{this.edgarCaller=edgarCaller;this.edgarPager=edgarPager;this.otciqCaller=otciqCaller;this.otciqPager=otciqPager;this.forumsCaller=forumsCaller;this.commonCaller=commonCaller;this.contentCaller=contentCaller;this.body=body;this.pageSize=pageSize;this.tabValue=tabValue;this.haveFetchNoFRMsg=false;this.pageHistory=pageHistory;this.glossaryDecorator=new GlossaryDecorator(this.contentCaller);this.quotePage=new QuoteSimple(this.otciqCaller,this.edgarCaller,this.commonCaller,new QuoteDashboardDOM(),undefined,new InsideDOM(),new MontageDOM(),new TradeDashboardDOM(),new SnapshotTradeHtml(),APPLICATION_ID_OTCQX);this.quotePage.gotoMarketMaker=undefined;this.quotePage.doRefresh=this.doQuoteRefresh;this.quotePage.handleRefresh=this.handleQuoteRefresh;this.chart=new EdgarChartAdvancedSimple(this.edgarCaller,new EdgarChartAdvancedDOM(),undefined,this,this.contentCaller);this.newsHandler=new ListNewsReleaseSimple(this.otciqCaller,new ListNewsReleaseHtml(),this.pageSize,undefined,this.otciqPager);this.companyProfile=new CompanyProfileSimple(commonCaller,new PinkCompanyProfileDOM());this.financialReports=new ListFinancialReportSimple(this.otciqCaller,new ListFinancialReportHtml(),this.pageSize,undefined,new FinancialStatementHtml(),this.otciqPager);this.edgarFilings=new ListFilingsSimple(this.edgarCaller,new ListFilingsMini(),this.pageSize,undefined,this.edgarPager);this.edgarNews=new ListEdgarNewsSimple(this.edgarCaller,new ListEdgarNewsMini(),this.pageSize,undefined);this.shoHandler=new ShoHistoryWorklistSimple(commonCaller,new ShoHistoryWorklistDOM(),undefined,this,this.pageSize);this.shortInterestHandler=new ShortInterestWorklistSimple(commonCaller,new ShortInterestWorklistDOM(),undefined,this,this.pageSize);this.insiderSummary=new InsiderSummarySimple(this.edgarCaller,new InsiderSummaryDOM(),undefined,this);this.insiderTrans=new ListInsiderTransSimple(this.edgarCaller,new ListInsiderTransMini(),this.pageSize,undefined);this.timeAndSales=new TimeAndSalesResultsSimple(commonCaller,new TimeAndSalesResultsDOM(),this,PAGE_SIZE_WORKLIST);this.quoteHeader=new QuoteHeaderSimple(this.otciqCaller,undefined,'QX');this.quoteHeader.generate=this.generateQuoteHeader;this.anchorList=new AnchorList();this.tierLogo=new TierLogoHtml(true);this.tierLogo.URL_GUIDE='#';this.baseUrls={rssUrl:'http://syndicate.pinksheets.com/syndicate/rss.xml'};var callback=new AjaxDataHandler(this);callback.handleRequestData=function(value){value.rssUrl=value.syndicateBaseUrl+'/rss.xml';this.callback.baseUrls=value;};this.commonCaller.getBaseUrls(callback);}
QuoteHandler.defaultCanBlockQuote=false;QuoteHandler.getInstance=function(tabValue,pageHistory,showMMInfo,canBlockQuote)
{var value=new QuoteHandler(new PinkEdgarCalls(),new EdgarAppNav(),iqCaller,new OtcIQAppNav(),undefined,undefined,commonCaller,undefined,PAGE_SIZE_SUBLISTING,new PinkContentCalls(),tabValue,pageHistory);value.quotePage.showMMInfo=showMMInfo;value.quotePage.hasBB=showMMInfo;value.canBlockQuote=(undefined==canBlockQuote)?QuoteHandler.defaultCanBlockQuote:canBlockQuote;return value;}
QuoteHandler.prototype.TAB_INDEX_QUOTE=0;QuoteHandler.prototype.TAB_INDEX_NEWS=1;QuoteHandler.prototype.TAB_INDEX_CHARTS=2;QuoteHandler.prototype.TAB_INDEX_COMPANY_INFO=3;QuoteHandler.prototype.TAB_INDEX_FILINGS=4;QuoteHandler.prototype.TAB_INDEX_SHORT_INTEREST=5;QuoteHandler.prototype.TAB_INDEX_INSIDER_TRANS=6;QuoteHandler.prototype.TAB_INDEX_FORUMS=7;QuoteHandler.prototype.QUOTE_BLOCK_URI='/pinksheets/quoteBlock';QuoteHandler.prototype.UP_ICON='/corporate/images/icon-positive.png';QuoteHandler.prototype.DOWN_ICON='/corporate/images/icon-negative.png';QuoteHandler.prototype.TAB_CAPTIONS_EQUITY=['Quote','Charts','Profile'];QuoteHandler.prototype.TAB_CALLS_EQUITY=['getQuote','getCharts','getCompanyInfo'];QuoteHandler.prototype.QUOTE_UPDATE_TIMEOUT=60000;QuoteHandler.prototype.doSecurity=function(security,body)
{this.run(new QuoteHandlerCriteria(security,this.tabValue),body);}
QuoteHandler.prototype.run=function(criteria,body)
{if(undefined!=body)
criteria.body=body;else if(undefined==criteria.body)
criteria.body=this.body;if(undefined!=this.quoteDaemonId)
{window.clearInterval(this.quoteDaemonId);this.quoteDaemonId=undefined;}
this.quotePage.callback=this.createTradeInfoAndInsideHandlers(criteria);var security=criteria.security;criteria.haveCheckedQuoteBlock=!(this.canBlockQuote&&security.isCaveatEmptor);criteria.hasInactiveReports=undefined;criteria.edgarCompany=undefined;criteria.isBankrupt=((5==security.symbol.length)&&('Q'==security.symbol.substr(4,1)));var companyLogo=document.getElementById('companyLogo');criteria.hasLogo=(!security.isCaveatEmptor&&(TIER_NO_INFO>security.tierId)&&this.otciqCaller.hasActiveCompanyLogo(security.compId));this.prepareTabs(criteria,body);this.lastCriteria=criteria;}
QuoteHandler.prototype.generateQuoteHeader=function(value,callback)
{var record=value.security;var b,c,d,e,a=document.createElement('div');a.className='quoteHeader';d=document.createElement('div');d.className='companyInfo';a.appendChild(d);d.appendChild(b=document.createElement('h2'));b.appendChild(c=document.createElement('strong'));c.innerHTML=record.companyName;b.appendChild(document.createTextNode(' - '+record.symbol));d.appendChild(b=document.createElement('div'));b.className='brief';b.innerHTML=record.tierName+' / <strong>Security Type: </strong>'+record.className;a.appendChild(b=document.createElement('div'));b.className='titleSection';b.appendChild(c=document.createElement('ul'));c.className='brief';c.appendChild(d=document.createElement('li'));d.className='large';d.appendChild(e=value.priceBody=document.createElement('span'));d.appendChild(e=value.directionIcon=document.createElement('img'));c.appendChild(d=value.changeBody=document.createElement('li'));c.appendChild(d=value.insidePriceBody=document.createElement('li'));c.appendChild(d=value.insideQuantityBody=document.createElement('li'));c.appendChild(d=value.volumeBody=document.createElement('li'));c.appendChild(d=value.timeBody=document.createElement('li'));a.appendChild(c=value.tabBody=document.createElement('div'));c.className='widgetPackage';c.id='quoteTabberContainer';return a;}
QuoteHandler.prototype.getEdgarCompany=function(criteria)
{if(undefined==criteria.edgarCompany)
{try
{criteria.edgarCompany=this.edgarCaller.getCompanyBySymbol(criteria.symbol);if(undefined==criteria.edgarCompany)
criteria.edgarCompany={isUnavailable:true};}
catch(error){criteria.edgarCompany={isError:true};}}
return criteria.edgarCompany;}
QuoteHandler.prototype.getEdgarCompanyId=function(criteria)
{return this.getEdgarCompany(criteria).id;}
QuoteHandler.prototype.changeTab=function(index)
{this.tabber.setActiveTab(index);}
QuoteHandler.prototype.getQuote=function(criteria,body)
{if(!criteria.haveCheckedQuoteBlock)
{criteria.quoteBlock=this.commonCaller.getQuoteBlock(criteria.securityId);if(undefined!=criteria.quoteBlock)
criteria.quoteBlock.comments=this.contentCaller.getPageText(undefined,this.QUOTE_BLOCK_URI).contents;criteria.haveCheckedQuoteBlock=true;}
body.innerHTML='';if(criteria.isBankrupt)
body=this.createExtraQuoteSection('Bankruptcy Warning','/content/doc/ps/images/bankrupt_banner.gif','http://www.sec.gov/investor/pubs/bankrupt.htm',body);if(undefined!=criteria.quoteBlock)
body.innerHTML=criteria.quoteBlock.comments;else
{this.doQuote(criteria,body);if(undefined==this.quoteDaemonId)
{var me=this;this.quoteDaemonId=window.setInterval(function(){me.doDaemon(criteria,body);},this.QUOTE_UPDATE_TIMEOUT);}}}
QuoteHandler.prototype.doQuoteRefresh=function(criteria){this.run(criteria);this.callback.callback.chart.doSymbolSnapShot(criteria.symbol,criteria.body.myChart,APPLICATION_ID_CORP);}
QuoteHandler.prototype.handleQuoteRefresh=function(ev){this.myCallback.run(this.myValue);criteria=this.myValue;this.myCallback.callback.callback.chart.doSymbolSnapShot(criteria.symbol,criteria.body.myChart,APPLICATION_ID_CORP);}
QuoteHandler.prototype.doQuote=function(criteria,body)
{this.quotePage.doSec(criteria.security,body);this.chart.doSymbolSnapShot(criteria.symbol,body.myChart,APPLICATION_ID_CORP);var gd=this.glossaryDecorator;window.setTimeout(function(){gd.doSection(body);},2000);}
QuoteHandler.prototype.generate=function(value){var body=value.body;var div=body.quoteHeaderBody=document.createElement('div');div.id='quoteHeader';body.appendChild(div);body.appendChild(div=body.tabDetailBody=document.createElement('div'));div.id='tabDetail';}
QuoteHandler.prototype.createExtraQuoteSection=function(title,imgSrc,link,body)
{body.appendChild(document.createElement('br'));var div=document.createElement('div');div.style.width='100%';div.style.textAlign='center';div.style.padding='0px';var a=document.createElement('a');a.href=link;a.target='_blank';var img=document.createElement('img');img.border=0;img.src=imgSrc;img.title=title;img.alt=title;a.appendChild(img);div.appendChild(a);body.appendChild(div);body.appendChild(document.createElement('br'));body.appendChild(document.createElement('br'));div=document.createElement('div');body.appendChild(div);return div;}
QuoteHandler.prototype.getCharts=function(criteria,body)
{var filter=new EdgarChartFilter(criteria.symbol,false,undefined,3);filter.appId='CORP';this.chart.run(new EdgarChartAdvancedCriteria(filter,body));}
QuoteHandler.prototype.getCompanyInfo=function(criteria,body)
{this.companyProfile.doSecurity(criteria.securityId,body);}
QuoteHandler.prototype.handleAnchorSelect=function(id,value,criteria_)
{var criteria=criteria_.parent;this.financialReports.run(new ListFinancialReportCriteria(criteria.companyId,id),criteria.filingsBody);}
QuoteHandler.prototype.createSection=function(caption)
{var tr,output=document.createElement('table');output.className='sectional';output.style.width='100%';output.myCaption=output.createCaption();if(undefined!=caption)
output.myCaption.appendChild(document.createTextNode(caption));tr=output.insertRow(0);output.myBody=tr.insertCell(0);output.myBody.style.paddingTop='6px';return output;}
QuoteHandler.prototype.createTabberOptions=function(criteria)
{var defaultTab=(undefined==criteria.tabValue)?0:criteria.tabValue;var value={'defaultTab':defaultTab,'onClick':function(args){var call=this.calls[args.index];var symbol=this.symbol;logThisPageHit('/quote/'+call+'?symbol='+symbol,symbol);if(!args.tab.isEmpty)
return true;args.tab.body.innerHTML='';this.callback.generate({'body':args.tab.body});try{if(args.index==0)
args.tab.body.quoteHeaderBody.appendChild(this.callback.generateQuoteHeader(this.criteria));else
this.callback.quoteHeader.run(this.criteria,args.tab.body.quoteHeaderBody);this.callback[call](this.criteria,args.tab.body.tabDetailBody);}
catch(error){window.alert(error);return false;}
this.callback.pageHistory.add(call,this.callback,'changeTab',args.index);resetFavicon();args.tab.isEmpty=false;return true;},'onLoad':function(args){this.onClick(args);},symbol:criteria.symbol}
value.titles=this.TAB_CAPTIONS_EQUITY;value.calls=this.TAB_CALLS_EQUITY;value.criteria=criteria;value.callback=this;return value;}
QuoteHandler.prototype.prepareTabs=function(criteria)
{this.tabber=new Tabbers(this.createTabberOptions(criteria));criteria.body.innerHTML='';this.tabber.run(criteria.body);}
QuoteHandler.prototype.doDaemon=function(criteria,body)
{this.doQuote(criteria,body);}
QuoteHandler.prototype.createTradeInfoAndInsideHandlers=function(criteria)
{return callback={criteria:criteria,callback:this,handleTradeInfo:function(value)
{if(value==undefined)
return;var a=this.criteria;if(undefined!=value.lastSale)
a.priceBody.innerHTML=Formatter.toPrice(value.lastSale);if(undefined!=value.volume)
a.volumeBody.innerHTML='<strong>V </strong>'+Formatter.toVolume(value.volume);if(undefined!=value.change)
a.changeBody.innerHTML=Formatter.toPrice(value.change)+' ('+Formatter.toPercent(value.percentChange)+'%)';a.timeBody.innerHTML=Formatter.toQuoteTime(value.quoteTime);var className=(0>value.change)?'negative':(0<value.change)?'positive':'';a.priceBody.className=' '+className;a.changeBody.className=' '+className;if(className){a.directionIcon.style.display='inline';a.directionIcon.src='/corporate/images/icon-'+className+'.png';}
else
a.directionIcon.style.display='none';},handleInside:function(value)
{var a=this.criteria;if(value==undefined){a.insidePriceBody.innerHTML='No Inside Market';return;}
a.insidePriceBody.innerHTML=value.bidPrice+'/'+value.askPrice;a.insideQuantityBody.innerHTML=value.bidSize+'/'+value.askSize;}};}
function QuoteHandlerCriteria(security,tabValue)
{this.security=security;this.securityId=security.secId;this.symbol=security.symbol;this.companyId=security.compId;this.tabValue=tabValue;}