
function C_SignupDialog()
{this.window=null;this.show=function(params)
{this.teamID=params.teamID;this.teamName=params.teamName;if(!this.window)
{this.dsTeamLookup=new Ext.data.JsonStore({root:'results',totalProperty:'rowcount',idProperty:'TeamID',fields:[{name:'TeamID',type:'int'},{name:'TeamName'},{name:'TeamType'},{name:'Domain'}],proxy:new Ext.data.HttpProxy({url:'/data/lookup-team.php'})});this.form=new Ext.form.FormPanel({baseCls:'x-plain',url:'/data/signup.php',labelAlign:'right',labelWidth:40,bodyStyle:'padding: 7px 15px 0px 15px',buttonAlign:'center',baseParams:{},items:[{xtype:'container',layout:'column',items:[{xtype:'container',layout:'form',width:210,labelWidth:40,items:[{xtype:'textfield',fieldLabel:'Name',emptyText:'First Name',name:'FirstName',width:160,allowBlank:false,blankText:'You must enter your first name'}]},{xtype:'container',layout:'form',width:165,hideLabels:true,items:[{xtype:'textfield',emptyText:'Last Name',name:'LastName',width:165,allowBlank:false,blankText:'You must enter your last name'}]}]},{xtype:'textfield',fieldLabel:'Email',emptyText:'name@example.com',name:'Email',width:330,vtype:'email',allowBlank:false,blankText:'You must enter your email'},{xtype:'remotecombobox',fieldLabel:'Team',displayField:'TeamName',valueField:'TeamID',hiddenName:'TeamID',forceSelection:true,maxHeight:400,width:330,listWidth:350,pageSize:50,triggerClass:'x-form-search-trigger',emptyText:'Type first few letters of your team name...',store:this.dsTeamLookup,tpl:'<tpl for="."><div class="x-combo-list-item" style="border-bottom:1px solid #ccc"><table cellpadding=0 cellspacing=0><tr>\
                           <td><div class="ellipses" style="padding-left:5px;width:210px">\
                             <div class="find-name">{TeamName}</div>\
                             <div class="find-info">{TeamType}</div>\
                           </div></td>\
                           <td style="height:32px;width:120px;text-align:center"><img src="'+getFullDomainRoot()+'/imgstore/team-logo/fit/{TeamID}.png"></td>\
                         </tr></table>\
                         </div></tpl>'},{xtype:'container',style:'padding:5px 0 5px 180px',html:'OR...'},{xtype:'checkbox',name:'NoTeam',boxLabel:'No team - just sign me up <span style="font-size:11px;line-height:12px;color:#888">(you can always join a team later)</span>'},{xtype:'checkbox',name:'CreateTeam',boxLabel:'I want to create a new team <span style="font-size:11px;line-height:12px;color:#888">(we will contact you via email)</span>'},{xtype:'container',cls:'form-spacer',height:5},{xtype:'container',id:'status-msg',style:'display:none',cls:'form-status'},{xtype:'container',cls:'form-spacer',height:2}],buttons:[{text:'Sign Up!',width:140,handler:this.saveButtonClick,scope:this}]});this.window=new Ext.Window({title:'RideNet Sign Up',width:440,y:150,autoHeight:true,forceLayout:true,resizable:false,closeAction:'hide',modal:true,bodyStyle:'padding:5px;',items:this.form});this.window.on('show',function(){this.form.getForm().reset();if(this.teamID)
{this.form.getForm().findField("TeamID").setValue(this.teamID);this.form.getForm().findField("TeamID").setRawValue(this.teamName);}
this.setMessage('','black');},this);}
this.window.show(params.animateTarget);}
this.saveButtonClick=function()
{this.setMessage("Creating Profile...","black",true);this.window.getEl().mask();this.form.getForm().submit({reset:false,params:{Source:g_signupSource},success:this.onPostSuccess,failure:this.onPostFailure,scope:this});}
this.onPostSuccess=function(form,action)
{var team=this.form.getForm().findField("TeamID").getRawValue();team=(this.form.getForm().findField("NoTeam").getValue()==true||this.form.getForm().findField("TeamID").getRawValue()=='')?'(No Team)':team;_gaq.push(['_trackEvent','Signup',g_signupSource,team]);Ext.Msg.show({title:"RideNet Sign Up",msg:"<span style='font-size:14px'>Thank you for signing up with RideNet! We will send you a welcome email with login information.</span>",closable:false,buttons:Ext.MessageBox.OK,fn:function(btn){this.window.getEl().unmask();this.window.hide();},scope:this});}
this.onPostFailure=function(form,action)
{this.window.getEl().unmask();switch(action.failureType){case Ext.form.Action.CLIENT_INVALID:this.setMessage("Fields marked in red are required.","red");break;case Ext.form.Action.SERVER_INVALID:this.setMessage(action.result.message,"red");break;case Ext.form.Action.CONNECT_FAILURE:this.setMessage("Error requesting membership: Server did not respond","red");break;}}
this.setMessage=function(message,color,loading)
{setFormMessage(message,color,loading);this.window.syncSize();}}
