
function UpdateCompanyProfileSimple(caller,viewer,body,contentCaller,callback)
{this.caller=caller;this.viewer=viewer;this.body=body;this.contentCaller=contentCaller;this.callback=callback;this.criteria=undefined;}
UpdateCompanyProfileSimple.prototype.init=function()
{this.caller.getCompanyProfilePO(undefined,new UpdateCompanyProfileHandlePO(this));}
UpdateCompanyProfileSimple.prototype.doSecurity=function(securityId,body)
{this.run(new CompanyProfileCriteria(undefined,securityId),body);}
UpdateCompanyProfileSimple.prototype.doSecurityInfo=function(value,body)
{var criteria=new CompanyProfileCriteria(value.compId);criteria.securityInfo=value;this.run(criteria,body);}
UpdateCompanyProfileSimple.prototype.doCompany=function(companyId,body)
{var me=this;this.caller.getUserMin({handleRequestData:function(user)
{var criteria=new CompanyProfileCriteria(companyId,undefined);var formInfo=criteria.formInfo=new Object();formInfo.contactAffiliation='OTCIQ User';formInfo.contactFirstName=user.firstName;formInfo.contactLastName=user.lastName;formInfo.contactEmail=user.emailAddress;formInfo.contactPhone=user.phone;formInfo.companyId=companyId;formInfo.userId=user.id;me.run(criteria,body);}});}
UpdateCompanyProfileSimple.prototype.run=function(criteria,body)
{var noSecurity=(undefined==criteria);if(noSecurity)
criteria=new CompanyProfileCriteria();if(undefined!=body)
criteria.body=body;else if(undefined==criteria.body)
criteria.body=this.body;this.criteria=criteria;if(noSecurity)
{this.caller.getCompanyProfilePO(undefined,new UpdateCompanyProfileHandlePO(criteria));var theForm,value=new Object();value.criteria=criteria;criteria.body.innerHTML='';criteria.body.appendChild(theForm=this.viewer.generate(value,this));theForm.elements[0].focus();}
else
this.caller.getCompanyProfile(criteria.companyId,criteria.securityId,this);}
UpdateCompanyProfileSimple.prototype.handleRequestData=function(value)
{if(undefined!=value.fiscalYearEnd)
{var vals=value.fiscalYearEnd.split('/');if(2==vals.length)
{value.fiscalMonthEnd=vals[0];value.fiscalDayEnd=vals[1];}}
var theForm;var criteria=this.criteria;criteria.formInfo.origName=value.name;if(undefined==criteria.pageInfo)
{if(undefined!=this.pageInfo)
criteria.pageInfo=this.pageInfo;else
{criteria.pageInfo=this.pageInfo=this.caller.getCompanyProfilePO();UpdateCompanyProfileHandlePO.fix(criteria.pageInfo);}}
value.criteria=criteria;criteria.body.innerHTML='';criteria.body.appendChild(theForm=this.viewer.genForm(value,this));if(this.callback.handlePostLoad)
this.callback.handlePostLoad(theForm);}
UpdateCompanyProfileSimple.prototype.handleSymbolEntry=function(value)
{var security=this.caller.getSecurityInfo(value.symbol);if(undefined==security)
{window.alert('The symbol, '+value.symbol+', is not valid.');return false;}
var criteria=value.criteria;if(this.caller.hasAccount(value.symbol))
{criteria.body.innerHTML='';criteria.body.appendChild(this.viewer.genHasAccount(value,this));return true;}
value.origSymbol=value.symbol;value.criteria=undefined;criteria.formInfo=value;criteria.companyId=security.compId;this.run(criteria);return true;}
UpdateCompanyProfileSimple.prototype.handleSubmit=function(ev)
{var me=this.myCallback;var value=this.myValue;var criteria=value.criteria;var theForm=this.form;try
{var status=me.caller.updateCompanyProfile(criteria.formInfo);if(status.isOk)
{criteria.body.innerHTML='';criteria.body.appendChild(me.viewer.genConfirm(value,me));window.scrollTo(0,0);}
else
{window.alert(status.message);}}
catch(error){window.alert(error);}}
UpdateCompanyProfileSimple.prototype.popStates=function(criteria,field,countryId,stateId)
{var callback=new UpdateCompanyProfileStateHandler(criteria,field,countryId,stateId);if(undefined==criteria.states)
criteria.states=new Object();var value=criteria.states[countryId];if(undefined!=value)
callback.doValue(value);else
this.caller.getStatesXAsListItemsByCountry(countryId,callback);}
UpdateCompanyProfileSimple.prototype.getContents=function(name)
{var value=this.contentCaller.getPageText(undefined,name);if(undefined==value)
return undefined;return value.contents;}
function UpdateCompanyProfileHandlePO(criteria)
{this.criteria=criteria;}
UpdateCompanyProfileHandlePO.fix=function(value)
{value.businessStages.ids=value.businessStages.values;value.securityManuals.ids=value.securityManuals.values;value.sicCodes.ids=value.sicCodes.values;value.titles.ids=value.titles.values;}
UpdateCompanyProfileHandlePO.prototype.handleRequestData=function(value)
{this.criteria.pageInfo=value;UpdateCompanyProfileHandlePO.fix(value);}
function UpdateCompanyProfileStateHandler(criteria,field,countryId,stateId)
{this.criteria=criteria;this.field=field;this.countryId=countryId;this.stateId=stateId;}
UpdateCompanyProfileStateHandler.prototype.handleRequestData=function(value)
{this.criteria.states[this.countryId]=value;this.doValue(value);}
UpdateCompanyProfileStateHandler.prototype.doValue=function(value)
{var options=this.field.options;options.length=0;if(0==value.ids.length)
options[0]=new Option('No States','');else
{options[0]=new Option('Select One','');for(var i=0;i<value.ids.length;i++)
options[options.length]=new Option(value.values[i],value.ids[i]);if(undefined!=this.stateId)
this.field.value=this.stateId;}}