
function paintpage(tab,symbol){var body=document.getElementById('centerContentOneCol');pageHistory.start();var handler=QuoteHandler.getInstance((tab==undefined)?0:tab,pageHistory);handler.doSymbol(symbol,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 QuoteDOM(),undefined,new InsideDOM(),new MontageDOM(),new TradeDOM(),new SnapshotTradeHtml(),APPLICATION_ID_OTCQX);this.quotePage.gotoMarketMaker=undefined;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 CompanyProfileDOM());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);var me=this;this.resources=new ListResourcesSimple(this.otciqCaller,ListResourcesDOM,this.pageSize,undefined,{handleNews:function(v,r){me.newsHandler.showContents(r,v,me.resources);},handleFR:function(v,r){me.otciqPager.openFinancialReport(r.id);}});this.anchorList=new AnchorList();this.activityListCriteria=new AnchorListCriteria(this.STATUS_OPTIONS,STATUS_ID_ACTIVE,this,undefined,' | ');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.prototype.NO_RESEARCH_REPORTS_MESSAGE='No Research Reports';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.QUOTE_BLOCK_URI='/pinksheets/quoteBlock';QuoteHandler.prototype.NO_FINANCIAL_REPORTS_MESSAGE_URI='/pinksheets/noFinancialReportsMessage';QuoteHandler.prototype.TAB_CAPTIONS_EQUITY=['Quote','Charts','Company Info','News','Financials','Short Interest','Insider Transactions','Research Reports'];QuoteHandler.prototype.TAB_CALLS_EQUITY=['getQuote','getCharts','getCompanyInfo','getNews','getFilings','getShortInfo','getInsiderTrans','getResearchReports'];QuoteHandler.prototype.TAB_CAPTIONS_DEBT=['Quote','Company Info','Financials','Short Interest'];QuoteHandler.prototype.TAB_CALLS_DEBT=['getQuote','getCompanyInfo','getFilings','getShortInfo'];QuoteHandler.prototype.RSS_ICON='/content/doc/ps/logos/rss/small.gif';QuoteHandler.prototype.RSS_FR_TITLE='The Pink OTC Markets RSS feed only includes filings published via the OTC Disclosure and News Service.';QuoteHandler.prototype.RSS_PR_TITLE='The Pink OTC Markets RSS feed only includes news stories published via the OTC Disclosure and News Service.';QuoteHandler.prototype.STATUS_OPTIONS={ids:[STATUS_ID_ACTIVE,STATUS_ID_INACTIVE],values:[CAPTION_ACTIVE,CAPTION_INACTIVE]};QuoteHandler.prototype.QUOTE_UPDATE_TIMEOUT=60000;QuoteHandler.prototype.IMAGE_NEGATIVE_URL='/common/images/icons/icon-negative.png';QuoteHandler.prototype.IMAGE_POSITIVE_URL='/common/images/icons/icon-positive.png';QuoteHandler.prototype.doId=function(id,body)
{var value=this.commonCaller.getSecurityInfoById(id);if(undefined==value)
throw'Invalid security ID, '+id+'.';this.doSecurity(value,body);}
QuoteHandler.prototype.doSymbol=function(symbol,body)
{var value=this.commonCaller.getSecurityInfo(symbol);if(undefined==value)
throw'Invalid security symbol, '+symbol+'.';this.doSecurity(value,body);}
QuoteHandler.prototype.doCusip=function(cusip,body)
{var value=this.commonCaller.getSecurityInfoByCusip(cusip);if(undefined==value)
throw'Invalid security CUSIP, '+cusip+'.';this.doSecurity(value,body);}
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.createTradeInfoHandler(criteria);var security=criteria.security;criteria.isDebt=((undefined==security.symbol)||(0==security.symbol.length));criteria.haveCheckedQuoteBlock=!(this.canBlockQuote&&security.isCaveatEmptor);criteria.hasInactiveReports=undefined;criteria.edgarCompany=undefined;if(criteria.isDebt)
{criteria.isBankrupt=false;criteria.isUnsolicited=false;}
else
{criteria.isBankrupt=((5==security.symbol.length)&&('Q'==security.symbol.substr(4,1)));criteria.isUnsolicited=this.otciqCaller.isSecurityUnsolicited(security.symbol);}
this.activityListCriteria.parent=criteria;var companyLogo=document.getElementById('companyLogo');criteria.hasLogo=(!security.isCaveatEmptor&&(TIER_NO_INFO>security.tierId)&&this.otciqCaller.hasActiveCompanyLogo(security.compId));body.appendChild(this.generate(criteria,this));this.prepareTabs(criteria);this.lastCriteria=criteria;}
QuoteHandler.prototype.generate=function(value,callback)
{var record=value.security;var b,c,d,e,a=document.createElement('div');a.className='quoteHeader';b=Elements.addElem(a,'h2');Elements.addElem(b,'strong',undefined,record.companyName+' - '+record.symbol);Elements.addDiv(a,'brief',record.tierName+' / <strong>Security Type: </strong>'+record.className);b=Elements.addDiv(a,'titleSection');c=Elements.addElem(b,'ul','brief');d=Elements.addElem(c,'li','quotePrice');value.lastTradeBody=Elements.addElem(d,'em');d=Elements.addElem(c,'li');Elements.addElem(d,'strong',undefined,'Change: ');value.changeBody=Elements.addElem(d,'em');d=Elements.addElem(c,'li');Elements.addElem(d,'strong',undefined,'Volume: ');value.volumeBody=Elements.addElem(d,'em');d=Elements.addElem(c,'li');Elements.addElem(d,'strong',undefined,'At: ');value.timeBody=Elements.addElem(d,'em');b=Elements.addDiv(a,'logoSection');if(value.hasLogo)
{b.appendChild(c=Elements.genImage(this.otciqCaller.getCompanyLogoSrc(record.compId)));c.className='compLogo';}
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);else if(criteria.isUnsolicited)
body=this.createExtraQuoteSection('Unsolicited Warning','/content/doc/ps/images/unsolicited_banner.gif','http://www.sec.gov/answers/unsolicitedquotations.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.doQuote=function(criteria,body)
{this.quotePage.doSec(criteria.security,body);var gd=this.glossaryDecorator;window.setTimeout(function(){gd.doSection(body);},2000);}
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.getNews=function(criteria,body)
{body.innerHTML='';var section=this.createSection('OTC Disclosure and News Service');var elem,img,div;div=document.createElement('span');div.className='rssLink';div.appendChild(img=document.createElement('img'));img.className='icon';img.src=this.RSS_ICON;img.border=0;img.title=this.RSS_PR_TITLE;elem=document.createElement('a');elem.href=this.baseUrls.rssUrl;elem.target='_new';elem.appendChild(document.createTextNode('Subscribe '));div.appendChild(elem);section.myCaption.appendChild(div);this.newsHandler.doCompany(criteria.companyId,section.myBody);body.appendChild(section);body.appendChild(document.createElement('br'));section=this.createSection('Other News Sources');var edgarCompanyId=this.getEdgarCompanyId(criteria);if(undefined!=edgarCompanyId)
this.edgarNews.doCompany(edgarCompanyId,section.myBody);else
section.myBody.innerHTML='No news found.';body.appendChild(section);}
QuoteHandler.prototype.getCharts=function(criteria,body)
{this.chart.doSymbol(criteria.symbol,body);}
QuoteHandler.prototype.getCompanyInfo=function(criteria,body)
{this.companyProfile.doSecurity(criteria.securityId,body);var me=this;window.setTimeout(function(){me.appendCompanyInfoDisclaimer(body);},2000);}
QuoteHandler.prototype.appendCompanyInfoDisclaimer=function(body)
{var p=document.createElement('div');p.className='footnote';body.appendChild(p)
p.appendChild(document.createTextNode(DISCLAIMER_COMPANY_INFO));}
QuoteHandler.prototype.getFilings=function(criteria,body)
{if(!this.haveFetchNoFRMsg)
{this.financialReports.viewer.NO_RECORDS_FOUND=this.contentCaller.getPageText(undefined,this.NO_FINANCIAL_REPORTS_MESSAGE_URI).contents;this.haveFetchNoFRMsg=true;}
if(undefined==criteria.hasInactiveReports)
criteria.hasInactiveReports=this.otciqCaller.hasInactiveReports(criteria.companyId);body.innerHTML='';var section=this.createSection('OTC Disclosure and News Service');var elem,img,div;div=document.createElement('span');div.className='rssLink';div.appendChild(img=document.createElement('img'));img.className='icon';img.src=this.RSS_ICON;img.border=0;img.title=this.RSS_PR_TITLE;elem=document.createElement('a');elem.href=this.baseUrls.rssUrl;elem.target='_new';elem.appendChild(document.createTextNode('Subscribe '));div.appendChild(elem);section.myCaption.appendChild(div);var tr=section.insertRow(0);var td=tr.insertCell(0);td.style.textAlign='right';if(this.hasInactiveReports)
{td.appendChild(elem=document.createElement('span'));this.anchorList.run(this.activityListCriteria,elem);td.appendChild(document.createTextNode(' | '));}
this.financialReports.doFilings(criteria.companyId,section.myBody);body.appendChild(section);criteria.filingsBody=section.myBody;if(!criteria.isDebt)
{body.appendChild(document.createElement('br'));section=this.createSection('SEC Filings');this.edgarFilings.doSymbol(criteria.symbol,section.myBody);body.appendChild(section);}}
QuoteHandler.prototype.handleAnchorSelect=function(id,value,criteria_)
{var criteria=criteria_.parent;this.financialReports.run(new ListFinancialReportCriteria(criteria.companyId,id),criteria.filingsBody);}
QuoteHandler.prototype.getShortInfo=function(criteria,body)
{body.innerHTML='';var section=this.createSection('SHO History');this.shoHandler.doSecurity(criteria.securityId,section.myBody);body.appendChild(section);body.appendChild(document.createElement('br'));section=this.createSection('Short Interest');this.shortInterestHandler.doSecurity(criteria.securityId,section.myBody);body.appendChild(section);}
QuoteHandler.prototype.getInsiderTrans=function(criteria,body)
{body.innerHTML='';var section=this.createSection();section.myCaption.innerHTML=TITLE_IQ_SERVICE;this.resources.doInsiderTrans(section.myBody,criteria.companyId);body.appendChild(section);Elements.addBreak(body);var DISPLAY=isIE?'block':'table';var summary=this.createSection();summary.style.display='none'
summary.myCaption.innerHTML='SEC Transaction Summary &mdash; Last 6 Months';this.insiderSummary.callback={handlePostLoad:function(value,output){if(0<value.numberOfTransactions)summary.style.display=DISPLAY;}};this.insiderSummary.doSymbol(criteria.symbol,summary.myBody);body.appendChild(summary);var trans=this.createSection();trans.style.display='none';trans.myCaption.innerHTML='SEC Transactions &mdash; Last 2 Years';this.insiderTrans.callback={handlePostLoad:function(value,output){if(value.records&&(0<value.records.length))trans.style.display=DISPLAY;}};this.insiderTrans.doSymbol(criteria.symbol,trans.myBody);body.appendChild(trans);}
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;try{this.callback[call](this.criteria,args.tab.body);}
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}
if(criteria.isDebt)
{value.titles=this.TAB_CAPTIONS_DEBT;value.calls=this.TAB_CALLS_DEBT;}
else
{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.tabBody.innerHTML='';this.tabber.run(criteria.tabBody);}
QuoteHandler.prototype.doDaemon=function(criteria,body)
{this.doQuote(criteria,body);}
QuoteHandler.prototype.createTradeInfoHandler=function(criteria)
{var me=this;return callback={criteria:criteria,callback:this,handleTradeInfo:function(value)
{var css='',b,a=this.criteria;b=a.lastTradeBody;b.innerHTML='&nbsp;&nbsp;'+Formatter.toPrice(value.lastSale);a.volumeBody.innerHTML=Formatter.toVolume(value.volume);a.changeBody.innerHTML=Formatter.toPrice(value.change)+' ('+Formatter.toPercent(value.percentChange)+'%)';a.timeBody.innerHTML=Formatter.toQuoteTime(value.quoteTime);if(0>value.change)
{css='negative';b.insertBefore(Elements.genImage(me.IMAGE_NEGATIVE_URL),b.firstChild);}
else if(0<value.change)
{css='positive';b.insertBefore(Elements.genImage(me.IMAGE_POSITIVE_URL),b.firstChild);}
b.className=a.changeBody.className=css;}};}
QuoteHandler.prototype.gotoMarketMaker=function(mmId){appNav.gotoMarketMakerDetail(mmId);}
function QuoteHandlerCriteria(security,tabValue)
{this.security=security;this.securityId=security.secId;this.symbol=security.symbol;this.companyId=security.compId;this.tabValue=tabValue;}
QuoteHandler.prototype.getResearchReports=function(criteria,body)
{var me=this;var callback={callback:me,criteria:criteria,body:body,handleRequestData:function(value){this.criteria.profile=value;this.callback.handleResearchReports(criteria,this.body);}};this.commonCaller.getCompanyProfile(criteria.compId,criteria.securityId,callback);}
QuoteHandler.prototype.handleResearchReports=function(criteria,body)
{body.innerHTML='';var hasReports=this.otciqCaller.hasResearchReports(criteria.companyId);var section,reports=criteria.profile.researchReports;body.appendChild(section=this.createSection('Issuer Sponsored Research Reports'));if(undefined==reports){section.myBody.className='noData';section.myBody.innerHTML=this.NO_RESEARCH_REPORTS_MESSAGE;}
else{section.myBody.appendChild(this.genResearchReports(reports));section.appendChild(document.createElement('br'));}
section=this.createSection(TITLE_IQ_SERVICE);body.appendChild(section);if(!hasReports){section.myBody.className='noData';section.myBody.innerHTML=this.NO_RESEARCH_REPORTS_MESSAGE;}
else
{this.financialReports.doResearchReports(criteria.companyId,section.myBody);}}
QuoteHandler.prototype.genResearchReports=function(values)
{var output=document.createElement('div');output.className='widgetPackage';for(var i=0;i<values.length;i++)
{if(0<i)
output.appendChild(document.createElement('br'));value=values[i];output.appendChild(Formatter.toWebsite(value.url,value.firmName));}
return output;}