
function CompanyWorklistDOM(){}
CompanyWorklistDOM.prototype=new WorklistDOM();CompanyWorklistDOM.prototype.generate=function(value,callback)
{var records=value.records;if((undefined==records)||(0==records.length))
return this.createNoDataFound(value,callback);var row,cell,rows=0,table=document.createElement('table');table.className=this.CSS_TABLE;row=table.insertRow(rows++);row.className=this.CSS_HEADER;this.createHeaderCell(row,0,CAPTION_NAME,FIELD_NAME,FIELD_ASCENDING,value,callback);this.createHeaderCell(row,1,CAPTION_LOCATION);this.createHeaderCell(row,2,CAPTION_SYMBOL,FIELD_SYMBOL,FIELD_ASCENDING,value,callback);this.createHeaderCell(row,3,CAPTION_TIER);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.name);this.createDetailCell(row,1,toDisplayable(record.location));cell=this.createDetailCell(row,2,'');if(record.symbol)
cell.appendChild(this.createSymbolAnchor(record,callback));else
row.fixMissingSymbolAnchor=true;this.createDetailCell(row,3,toDisplayable(record.primaryExchange));}
var output=document.createElement('div');output.appendChild(table);output.appendChild((new PagingLinksDOM()).generate(value,callback));return output;}

function ServiceProviderWorklistDOM(){}
ServiceProviderWorklistDOM.prototype=new WorklistDOM();ServiceProviderWorklistDOM.prototype.MMNote='The firms listed below are willing to discuss the Form 211 process with issuers.';ServiceProviderWorklistDOM.prototype.generate=function(value,callback)
{var records=value.records;if((undefined==records)||(0==records.length))
return document.createTextNode('No data found.');var table=document.createElement('table');table.className='listing';var rowNum=0;var row=table.insertRow(rowNum++);row.className='listingHeader';this.createHeaderCell(row,0,CAPTION_COMPANY_NAME,FIELD_NAME,FIELD_ASCENDING,value,callback);this.createHeaderCell(row,1,CAPTION_LOCATION,FIELD_LOCATION,FIELD_ASCENDING,value,callback);this.createHeaderCell(row,2,CAPTION_PHONE);this.createHeaderCell(row,3,CAPTION_WEBSITE);for(var i=0;i<records.length;i++)
{row=table.insertRow(rowNum++);row.className=alternateCssParentListingClasses(i);var record=records[i];this.createDetailCell(row,0,'').appendChild(this.createAnchor(record.name,record,callback));this.createDetailCell(row,1,toDisplayable(Formatter.toLocation(record)));this.createDetailCell(row,2,toDisplayable(record.phone));this.createDetailCell(row,3,'').appendChild(Formatter.toWebsite(record.website));}
var output=document.createElement('div');this.appendNote(output,value.criteria.type);output.appendChild(table);output.appendChild((new PagingLinksDOM()).generate(value,callback));return output;}
ServiceProviderWorklistDOM.prototype.appendNote=function(body,typeId)
{var note=this[typeId+'Note'];if(undefined==note)
return;var output=document.createElement('h3');output.innerHTML=note;body.appendChild(output);}
ServiceProviderWorklistDOM.prototype.createAnchor=function(caption,record,callback)
{var a=document.createElement('a');a.href='javascript:void(null)';a.appendChild(document.createTextNode(caption));a.onclick=function(ev){callback.handleSelection(record,this);return false;};return a;}

function ServiceProviderItemDetailDOM(){}
ServiceProviderItemDetailDOM.prototype.generate=function(record,callback)
{var elem,output=document.createElement('div');output.className='widgetPackage';output.appendChild(elem=document.createElement('h3'));elem.innerHTML=record.name;output.appendChild(elem=document.createElement('h4'));elem.innerHTML='Company Information';var table=document.createElement('table');table.className='subListing';var subRows=0;row=table.insertRow(subRows++);this.createDetailCaption(row,CAPTION_COMPANY_NAME);this.createDetailValue(row,record.name);row=table.insertRow(subRows++);this.createDetailCaption(row,CAPTION_LOCATION);this.createDetailNode(row,Formatter.toAddress(record));row=table.insertRow(subRows++);this.createDetailCaption(row,CAPTION_PHONE);this.createDetailValue(row,toDisplayable(record.phone));row=table.insertRow(subRows++);this.createDetailCaption(row,CAPTION_FAX);this.createDetailValue(row,toDisplayable(record.fax));row=table.insertRow(subRows++);this.createDetailCaption(row,CAPTION_WEBSITE);this.createDetailNode(row,Formatter.toWebsite(record.website));row=table.insertRow(subRows++);this.createDetailCaption(row,CAPTION_EMAIL_ADDRESS);this.createDetailNode(row,Formatter.toEmail(record.email));output.appendChild(table);return output;}
ServiceProviderItemDetailDOM.prototype.createDetailCaption=function(tr,value)
{var output=tr.insertCell(0);output.className='detailCaption';output.style.width='1%';output.style.whiteSpace='nowrap';output.appendChild(document.createTextNode(value));return output;}
ServiceProviderItemDetailDOM.prototype.createDetailValue=function(tr,value)
{var output=tr.insertCell(1);output.className='detailValue';output.colSpan=4;output.align='left';var txt=document.createTextNode(value);output.appendChild(txt);return output;}
ServiceProviderItemDetailDOM.prototype.createDetailNode=function(tr,node)
{var output=tr.insertCell(1);output.className='detailValue';output.colSpan=4;output.align='left';if(node)
output.appendChild(node);return output;}

function CompanyWorklistSimple(caller,viewer,body,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.body=body;this.pageSize=pageSize;this.callback=callback;}
CompanyWorklistSimple.prototype=new WorklistSimple();CompanyWorklistSimple.prototype.doAuditor=function(value,body)
{this.run({auditorId:value},body);}
CompanyWorklistSimple.prototype.doInvestorRelationsFirm=function(value,body)
{this.run({investorRelationsFirmId:value},body);}
CompanyWorklistSimple.prototype.doLegalCounsel=function(value,body)
{this.run({legalCounselId:value},body);}
CompanyWorklistSimple.prototype.doDadOrPal=function(value,body)
{this.run({dadOrPalId:value},body);}
CompanyWorklistSimple.prototype.doTransferAgent=function(value,body)
{this.run({transferAgentId:value},body);}
CompanyWorklistSimple.prototype.makeCall=function(criteria,dataHandler)
{this.caller.getCompanyWorklist(criteria,dataHandler);}
CompanyWorklistSimple.prototype.gotoQuote=function(ev)
{var me=this.myCallback;if(me.callback&&me.callback.gotoQuote)
me.callback.gotoQuote(this.myRecord.symbol);}

function ServiceProviderWorklistSimple(caller,viewer,body,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.body=body;this.pageSize=pageSize;this.callback=callback;}
ServiceProviderWorklistSimple.prototype=new WorklistSimple();ServiceProviderWorklistSimple.prototype.CMS_BANNED_ATTORNEYS='/pinksheets/otcguide/issuers/bannedAttorneys';ServiceProviderWorklistSimple.prototype.doDadPal=function(type,body)
{this.filter(new ServiceProviderWorklistFilter(type,true),body);}
ServiceProviderWorklistSimple.prototype.doType=function(type,body)
{if(type=='CMS')
{body.innerHTML='';(new PinkContentCalls()).getPageText(undefined,this.CMS_BANNED_ATTORNEYS,new PinkContentDataHandler(body));}
else
this.filter(this.newType(type),body);}
ServiceProviderWorklistSimple.prototype.newType=function(type){return new ServiceProviderWorklistFilter(type);}
ServiceProviderWorklistSimple.prototype.makeCall=function(filter,dataHandler)
{if('CS'==filter.type)
this.caller.getTransferAgentWorklist(filter,dataHandler);else
this.caller.getServiceProviderWorklist(filter,dataHandler);}
ServiceProviderWorklistSimple.prototype.handleSelection=function(record,elem)
{this.callback.handleDetail(record);}

function ServiceProviderDirectory(initialData,callback)
{this.callback=callback;this.commonCaller=new PinkCommonCalls();this.anchorList=new DropdownAnchors();this.defaultIndex=(undefined!=initialData.defaultIndex)?initialData.defaultIndex:this.DEFAULT_INDEX;this.defaultId=initialData.defaultId;this.listHandler=new ServiceProviderWorklistSimple(this.commonCaller,new ServiceProviderWorklistDOM(),undefined,PAGE_SIZE_WORKLIST,this);this.detailViewer=new ServiceProviderItemDetailDOM();var viewer=new CompanyWorklistDOM();viewer.NO_DATA_FOUND='None';this.companyListHandler=new CompanyWorklistSimple(this.commonCaller,viewer,undefined,PAGE_SIZE_WORKLIST,this);}
ServiceProviderDirectory.prototype.LIST_ITEMS={ids:['MM','AD','IR','LC','DAD','CS','CMS'],values:['211 Market Makers','Auditors/Accountants','Investor Relations','Legal Counsel','DADs & PALs','Transfer Agents','Prohibited Attorneys']};ServiceProviderDirectory.prototype.COMPANY_CALLS={AD:'doAuditor',IR:'doInvestorRelationsFirm',LC:'doLegalCounsel',DAD:'doDadOrPal',CS:'doTransferAgent'};ServiceProviderDirectory.prototype.DEFAULT_INDEX=0;ServiceProviderDirectory.prototype.INDEX_TRANSFER_AGENT=5;ServiceProviderDirectory.prototype.init=function(body)
{this.body=body;var ids=this.LIST_ITEMS.ids;var captions=this.LIST_ITEMS.values;var defaultTypeId=ids[this.defaultIndex];var defaultCaption=captions[this.defaultIndex];var output=body.myList=this.generate();body.appendChild(output);body.appendChild(body.myDetail=this.genDetail());body.myDetail.style.display='none';var anchorCriteria=new AnchorListCriteria(this.LIST_ITEMS,defaultTypeId,this,defaultCaption);anchorCriteria.myList=output.myContent;this.anchorList.run(anchorCriteria,output.myAnchors);this.lastTypeId=defaultTypeId;this.listHandler.doType(defaultTypeId,output.myContent);}
ServiceProviderDirectory.prototype.generate=function()
{var elem,output=document.createElement('table');output.cellSpacing=0;output.style.width='100%';var tr=output.insertRow(0);var td=tr.insertCell(0);td.style.whiteSpace='nowrap';td.style.width='5%';td.style.paddingRight='6px';td.className='h3';td.appendChild(document.createTextNode('Change Service Provider Type:'));td=output.myAnchors=tr.insertCell(1);output.myContent=td=output.insertRow(1).insertCell(0);td.style.paddingTop='6px';td.colSpan=2;return output;}
ServiceProviderDirectory.prototype.genDetail=function()
{var elem,output=document.createElement('div');output.appendChild(elem=document.createElement('a'));elem.href='javascript:void(null);';elem.appendChild(document.createTextNode('<< Back'));elem.onclick=this.handleBack;elem.myCallback=this;output.appendChild(document.createElement('br'));output.appendChild(document.createElement('br'));output.appendChild(output.myContent=document.createElement('div'));output.appendChild(document.createElement('br'));output.appendChild(elem=output.myCompaniesCaption=document.createElement('h4'));elem.innerHTML='Associated Companies/Securities';output.appendChild(output.myCompanies=document.createElement('div'));return output;}
ServiceProviderDirectory.prototype.handleAnchorSelect=function(id,caption,anchorCriteria)
{if((undefined!=this.callback)&&(undefined!=this.callback.handleChange))
this.callback.handleChange(id);this.lastTypeId=id;this.listHandler.doType(id,anchorCriteria.myList);}
ServiceProviderDirectory.prototype.handleDetail=function(record)
{var body=this.body;var detail=body.myDetail;detail.myContent.innerHTML='';detail.myContent.appendChild(this.detailViewer.generate(record,this));var call=this.COMPANY_CALLS[this.lastTypeId];if(call)
{this.companyListHandler[call](record.id,detail.myCompanies);detail.myCompaniesCaption.style.display='block';}
else
{detail.myCompanies.innerHTML='';detail.myCompaniesCaption.style.display='none';}
body.myList.style.display='none';detail.style.display='block';}
ServiceProviderDirectory.prototype.handleBack=function(ev)
{var body=this.myCallback.body;body.myDetail.style.display='none';body.myList.style.display='block';}
ServiceProviderDirectory.prototype.handlePostLoad=function(value,body)
{if(undefined!=this.defaultId)
{var me=this;var id=this.defaultId;var cb={handleRequestData:function(record){if(record)
me.handleDetail(record);}};this.defaultId=undefined;if(this.INDEX_TRANSFER_AGENT==this.defaultIndex)
this.commonCaller.getTransferAgent(id,cb);else
this.commonCaller.getServiceProvider(id,cb);}}
ServiceProviderDirectory.prototype.gotoQuote=function(symbol)
{if(this.callback&&this.callback.gotoQuote)
this.callback.gotoQuote(symbol);}
