/**
 * @author marklewis
 */
FOS.Organiser.Event.Participant.Detail = function(){
};

FOS.Organiser.Event.Participant.Detail.clubStore = new Ext.data.JsonStore({
    url: 'php/getClubs.php',
    root: 'data',
    fields: [{
        name: 'club_id'
    }, {
        name: 'name'
    }]
});



 

FOS.Organiser.Event.Participant.Detail.emails = new Ext.data.JsonStore({
    url: 'data.php',
    baseParams: {
        set: 'participants',
        subSet: 'emails'
    },
    root: 'data',
    fields: [{
        name: 'email'
    }]
});


 //


FOS.Organiser.Event.Participant.Detail.toolBarConfig = { 

		items: [{
            text: 'Generate Email',
			icon: 'resources/icons/email_add.png',
			tabIndex : 29,
            handler: function(){
				
				var now = new Date();
 					
					Ext.getCmp('email').suspendEvents();
					
 				 id = now.getYear().toString() + now.getMonth().toString() + now.getDay().toString() + now.getHours().toString() + now.getMinutes().toString() + now.getSeconds();
				 
            	 Ext.getCmp('email').setValue( id + '@fullonsport.co.uk');
				
             	Ext.getCmp('email').resumeEvents();
				Ext.getCmp('firstname').focus();
            }
        },{
            text: 'Save & New',
			icon: 'resources/icons/user_add.png',
			 hidden : false,
			 tabIndex : 30,
            handler: function(){
            	FOS.Organiser.Event.Participant.Detail.createNewAfterSave = true;
				FOS.Organiser.Event.Participant.Detail.save();
				
             
            }
        } ,{
            text: 'Save & Close',
			icon: 'resources/icons/disk.png',
			tabIndex : 31,
            handler: function(){
            	FOS.Organiser.Event.Participant.Detail.createNewAfterSave = false;
				FOS.Organiser.Event.Participant.Detail.save();
				
             
            }
        },         {
         text: 'Remove',
		 icon: 'resources/icons/user_delete.png',
		 tabIndex : 32, 
         handler: function(){
         
         mid = Ext.getCmp('eventParticipants').getSelectionModel().getSelected().data.member_id;
         eid = FOS.Organiser.Event.Participant.Detail.view.eventId;
         	FOS.Organiser.Event.Participant.Detail.destroy(eid, mid);
         	}
         }, 
        {
            text: 'Clear',
			icon: 'resources/icons/application_delete.png',
			tabIndex : 33,
            handler: function(){
                FOS.Organiser.Event.Participant.Detail.clear();
				Ext.getCmp('email').focus();
            }
        } 
      ]
	
};
	
	
	


FOS.Organiser.Event.Participant.Detail.viewConfig = {
	//title: 'Participant Details',
	xtype: 'panel',
	closeable: false,
	renderTo: 'participantDetail',
	 border: false,
	 frame: false,
	autoScroll: true,
	items: [{
		xtype: 'form',
		layout: 'form',
		id: 'participantDetail',
		
		padding: 10,
		
		items: [{
			layout: 'column',
			
			border: false,
			//bodyStyle: 'margin: 10px 0px 10px 0px',
			frame: false,
			items: [{
				xtype: 'textfield',
				hidden: true,
				id: 'memberId'
			
			}, {
				xtype: 'textfield',
				hidden: true,
				id: 'epId'
			
			}, {
				columnWidth: .5,
				layout: 'form',
				border: false,
				
				items: [{
				
					xtype: 'combo',
					hiddenName: 'selectedEventId',
					editable: true,
					tabIndex: 1,
					fieldLabel: 'Event',
					id: 'selectedEventId1',
					store: FOS.Organiser.Event.store,
					selectOnFocus: true,
					valueField: 'event_id',
					displayField: 'event_name',
					blankText: 'Select event',
					mode: 'local',
					triggerAction: 'all',
					anchor: '95%'
				
				}, {
					xtype: 'textfield',
					tabIndex: 3,
					fieldLabel: 'First Name',
					
					selectOnFocus: true,
					id: 'firstname',
					anchor: '95%',
					msgTarget: 'under',
					allowBlank: false,
					regex: /^[a-zA-Z_\- ]+$/,
					regexText: 'First must be alphabetic a-zA-Z only',
					listeners: {
					
						'blur': function(name){
							var s = name.getValue();
							
							name.setValue(s.toTitleCase());
						}
					}
				}, {
					xtype: 'textfield',
					name: 'dob',
					selectOnFocus: true,
					id: 'dob',
					tabIndex: 5,
					fieldLabel: 'DOB (DD/MM/YYYY)',
					allowBlank: false,
					msgTarget: 'under',
					width: 80,
					regex: /^\d{2}\/\d{2}\/\d{4}$/,
					regexText: 'DOB must be in the format DD/MM/YYYY',
					listeners: {
					
						'blur': function(dob){
						
							var s = "";
							
							s = dob.getValue();
							
							if (s.length == 6) {
								var ns = s.substring(0, 2) + '/';
								ns += s.substring(2, 4) + '/19';
								ns += s.substring(4, 6);
								
								dob.setValue(ns);
							}
							
						}
					}
				
				}, {
				
					xtype: 'combo',
					hiddenName: 'clubId',
					tabIndex: 7,
					editable: true,
					fieldLabel: 'Select existing club',
					id: 'club',
					store: FOS.Organiser.Event.Participant.Detail.clubStore,
					valueField: 'club_id',
					displayField: 'name',
					blankText: 'Please select a club...',
					mode: 'local',
					triggerAction: 'all',
					width: 300,
					selectOnFocus: true,
					anchor: '95%'
				}]
			}, {
				columnWidth: .5,
				layout: 'form',
				border: false,
				frame: false,
				items: [{
					xtype: 'textfield',
					id: 'email',
					tabIndex: 2,
					store: FOS.Organiser.Event.Participant.Detail.emails,
					fieldLabel: 'Email',
					displayField: 'email',
					vtype: 'email',
					typeAhead: false,
					typeAheadDelay: 1000,
					anchor: '100%',
					msgTarget: 'under',
					allowBlank: false,
					hideTrigger: true,
					selectOnFocus: true,
					value: 'enter@emailorlickgenerateemail.com' /*,
					listeners: {
					
						'blur': function(email){
						
						
							if (FOS.Organiser.Event.Participant.Detail.isMember == false) {
							
							
								if (email.getValue() != '' && email.getValue() != 'enter@emailorlickgenerateemail.com') {
								
									Ext.get('participantDetail').mask('Loading participant detail. Please wait...', 'x-mask-loading');
									
									Ext.Ajax.request({
										url: 'action.php',
										method: 'POST',
										params: {
											email: email.getValue(),
											action: 'check',
											module: 'participant',
											eventId: FOS.Organiser.viewingEventId
										},
										success: function(o, success, response){
										
											/*var or = Ext.decode(o.responseText);
											
											if (or.count == 1) {
												
												FOS.Organiser.Event.Participant.Detail.displayFormData(or.data);
												FOS.Organiser.Event.Participant.Detail.isMember = true;
												FOS.Organiser.Event.Participant.Detail.isEntered = false;
												
											}
											else {
												FOS.Organiser.Event.Participant.Detail.isMember = false;
												FOS.Organiser.Event.Participant.Detail.isEntered = false;
											}
											Ext.get('participantDetail').unmask();
										},
										failure: function(response, options){
											Ext.get('participantDetail').unmask();
											Ext.Msg.alert('Failed', response.status);
											
										}
									});
								}
							}
						}
					}*/
				}, {
					xtype: 'textfield',
					fieldLabel: 'Last Name',
					id: 'lastname',
					selectOnFocus: true,
					tabIndex: 4,
					anchor: '95%',
					msgTarget: 'under',
					allowBlank: false,
					regex: /^[a-zA-Z_\- ]+$/,
					regexText: 'First must be alphabetic a-zA-Z only',
					listeners: {
					
						'blur': function(name){
							var s = name.getValue();
							
							name.setValue(s.toTitleCase());
						}
					}
				}, {
					xtype: 'textfield',
					name: 'gender',
					selectOnFocus: true,
					id: 'gender',
					tabIndex: 5,
					fieldLabel: 'Gender (M/F)',
					allowBlank: false,
					msgTarget: 'under',
					width: 25,
					regex: /^[MmFf]+$/,
					regexText: 'Gender must be M = Male or F = Female',
					listeners: {
					
						'blur': function(name){
							var s = name.getValue();
							
							name.setValue(s.toTitleCase());
						}
					}
				}, {
					xtype: 'textfield',
					name: 'raceNo',
					id: 'raceNo',
					fieldLabel: 'Race Number',
					selectOnFocus: true,
					allowBlank: true,
					tabIndex: 6,
					value: 0,
					msgTarget: 'under',
					width: 120,
					regex: /^[A-Za-z0-9]+$/,
					regexText: 'Race number must be numbers and letters only'
				}, {
					xtype: 'textfield',
					selectOnFocus: true,
					id: 'entryPaid',
					tabIndex: 7,
					fieldLabel: 'Entry Fee Paid'
				}]
			}]
		}, {
			xtype: 'tabpanel',
			plain: true,
			frame: true,
			activeTab: 0,
			//layout: 'form',
			height: 350,
			/*
			 By turning off deferred rendering we are guaranteeing that the
			 form fields within tabs that are not activated will still be rendered.
			 This is often important when creating multi-tabbed forms.
			 */
			deferredRender: false,
			
			items: [{
				title: 'Contact Details',
				layout: 'form',
				frame: true,
				defaults: {
					width: 230,
					selectOnFocus: true
				},
				defaultType: 'textfield',
				xtype: 'panel',
				
				items: [{
					name: 'address1',
					
					tabIndex: 9,
					id: 'address1',
					fieldLabel: 'Address',
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				
				}, {
					name: 'address2',
					tabIndex: 10,
					id: 'address2',
					allowBlank: true,
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				
				}, {
					name: 'address3',
					tabIndex: 11,
					id: 'address3',
					allowBlank: true,
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				
				}, {
					name: 'city',
					tabIndex: 12,
					id: 'city',
					fieldLabel: 'City',
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				
				}, {
					name: 'region',
					tabIndex: 13,
					id: 'region',
					fieldLabel: 'County',
					width: 150,
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				
				}, {
					name: 'postcode',
					id: 'postcode',
					fieldLabel: 'Postcode',
					width: 100,
					tabIndex: 14,
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toUpper());
						}
					}
				}, {
					name: 'country',
					tabIndex: 15,
					id: 'country',
					fieldLabel: 'Country',
					width: 100,
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				}, {
					name: 'homeNo',
					tabIndex: 16,
					id: 'homeNo',
					fieldLabel: 'Home Telephone',
					width: 200,
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				}, {
					name: 'mobileNo',
					id: 'mobileNo',
					tabIndex: 17,
					fieldLabel: 'Mobile Telephone',
					width: 200,
					allowBlank: true
				}]
			}, {
				title: 'Emergency Contact Details',
				layout: 'form',
				frame: true,
				defaults: {
					width: 230
				},
				defaultType: 'textfield',
				xtype: 'panel',
				items: [{
					name: 'emergencyContactName',
					tabIndex: 18,
					id: 'emergencyContactName',
					fieldLabel: 'Emergency Contact Name',
					width: 200,
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				}, {
					name: 'emergencyContactNo',
					id: 'emergencyContactNo',
					tabIndex: 19,
					fieldLabel: 'Emergency Contact Telephone',
					width: 200,
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				}]
			}, {
				title: 'Club & Sports Body Details',
				layout: 'form',
				frame: true,
				defaults: {
					width: 230
				},
				defaultType: 'textfield',
				xtype: 'panel',
				items: [{
					xtype: 'checkbox',
					id: 'createNewClub',
					tabIndex: 20,
					fieldLabel: 'Create a new club'
				
				}, {
					xtype: 'textfield',
					id: 'newClubName',
					tabIndex: 21,
					fieldLabel: 'New Club name',
					width: 300,
					hidden: false,
					listeners: {
					
						'blur': function(t){
							var s = t.getValue();
							
							t.setValue(s.toTitleCase());
						}
					}
				}, {
					name: 'btfNo',
					id: 'btfNo',
					tabIndex: 222,
					fieldLabel: 'BTF Number'
				
				}, {
					name: 'ukAthleticsNo',
					id: 'ukAthleticsNo',
					tabIndex: 23,
					fieldLabel: 'UK Athletics Number'
				
				}]
			}, {
				cls: 'x-plain',
				title: 'Other Information',
				layout: 'fit',
				items: {
					xtype: 'htmleditor',
					tabIndex: 22,
					id: 'otherInformation',
					fieldLabel: 'Other Information',
					enableFont: true,
					enableFormat: true,
					enableFontSize: false,
					enableLinks: false,
					enableColors: false,
					enableAlignments: false,
					enableSourceEdit: false,
					enableLists: true
				
				}
			}, {
				cls: 'x-plain',
				title: 'Medical Information',
				layout: 'fit',
				items: {
					xtype: 'htmleditor',
					id: 'medicalInformation',
					fieldLabel: 'Medical Information',
					tabIndex: 23,
					enableFont: true,
					enableFormat: true,
					enableFontSize: false,
					enableLinks: false,
					enableColors: false,
					enableAlignments: false,
					enableSourceEdit: false,
					enableLists: true
				
				}
			}, {
				title: 'Time Estimates',
				xtype: 'panel',
				layout: 'form',
				frame: true,
				
				
				items: [{
					xtype: 'textfield',
					id: 'runTime1',
					tabIndex: 25,
					fieldLabel: 'Enter run time (hh:mm:ss)',
					value: '00:00:00',
					width: 65,
					regex: /^[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/,
					regexText: 'Time must be entered in hh:mm:ss (hours:minutes:seconds). Please use leading 0s and : where necessary',
					msgTarget: 'under'
				
				}, {
					xtype: 'textfield',
					id: 'swimTime',
					tabIndex: 26,
					fieldLabel: 'Enter swim time (hh:mm:ss)',
					value: '00:00:00',
					width: 65,
					regex: /^[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/,
					regexText: 'Time must be entered in hh:mm:ss (hours:minutes:seconds). Please use leading 0s and : where necessary',
					msgTarget: 'under'
				
				}, {
					xtype: 'textfield',
					id: 'bikeTime',
					tabIndex: 27,
					fieldLabel: 'Enter bike time (hh:mm:ss)',
					value: '00:00:00',
					width: 65,
					regex: /^[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/,
					regexText: 'Time must be entered in hh:mm:ss (hours:minutes:seconds). Please use leading 0s and : where necessary',
					msgTarget: 'under'
				}, {
					xtype: 'textfield',
					id: 'runTime',
					tabIndex: 28,
					fieldLabel: 'Enter run time (hh:mm:ss)',
					value: '00:00:00',
					width: 65,
					regex: /^[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/,
					regexText: 'Time must be entered in hh:mm:ss (hours:minutes:seconds). Please use leading 0s and : where necessary',
					msgTarget: 'under'
				
				},{
					xtype: 'textfield',
					id: 'waveNumber',
					tabIndex: 28,
					fieldLabel: 'Enter wave number',
					value: '0',
					allowBlank: true,
					width: 65,
					regex: /^[0-9]$/,
					regexText: 'Number only',
					msgTarget: 'under'
				
				},{
					xtype: 'textfield',
					id: 'positionNumber',
					tabIndex: 28,
					allowBlank: true,
					fieldLabel: 'Enter position number in wave',
					value: '0',
					width: 65,
					regex: /^[0-9]$/,
					regexText: 'Number only',
					msgTarget: 'under'
				
				},{
					xtype: 'textfield',
					id: 'laneNumber',
					allowBlank: true,
					tabIndex: 28,
					fieldLabel: 'Enter lane number in wave',
					value: '0',
					width: 65,
					regex: /^[0-9]$/,
					regexText: 'Number only',
					msgTarget: 'under'
				
				}]
			
			}]
		}],
		listeners: {
			afterrender: function(){
				Ext.getCmp('email').focus();
			}
			
		},
		
		//tbar: FOS.Organiser.Event.Participant.Detail.toolBarConfig,
		buttons: FOS.Organiser.Event.Participant.Detail.toolBarConfig
	
	}]
};


	


FOS.Organiser.Event.Participant.Detail.create = function(eid){
    FOS.Organiser.Event.Participant.Detail.show(eid);
    FOS.Organiser.Event.Participant.Detail.focus();
	 
};

FOS.Organiser.Event.Participant.Detail.edit = function(epid){

	
    FOS.Organiser.Event.Participant.Detail.show();
    
    Ext.get('participantDetail').mask('Loading participant detail. Please wait...', 'x-mask-loading');
	
    Ext.Ajax.request({
        url: 'action.php',
        method: 'POST',
        params: {
             
            action: 'read',
            module: 'participant',
			epId : epid
        },
        success: function(o, success, response){
        
            var or = Ext.decode(o.responseText);
            
			if (or.success == false) {
				Ext.get('participantDetail').unmask();
				Ext.MessageBox.alert('Load participant failed');
			}
			
            else if (or.count > 0) {
                FOS.Organiser.Event.Participant.Detail.displayFormData(or.data);
                FOS.Organiser.Event.Participant.Detail.isMember = true;
                FOS.Organiser.Event.Participant.Detail.isEntered = true;
                
            }
            else {
                FOS.Organiser.Event.Participant.Detail.isMember = false;
                FOS.Organiser.Event.Participant.Detail.isEntered = false;
                
            }
			
			Ext.get('participantDetail').unmask();
			
			FOS.Organiser.Event.Participant.Detail.focus('email');
			
        },
		failure: function(response, options){
            Ext.get('participantDetail').unmask();
            Ext.Msg.alert('Failed', response.status);
            
        }
    });
    
};
 

FOS.Organiser.Event.Participant.Detail.destroy = function(eid, mid){
    
	if (Ext.get('participantDetail'))
		Ext.get('participantDetail').mask('Deleting participant detail. Please wait...', 'x-mask-loading');
	
	Ext.Ajax.request({
        url: 'action.php',
        method: 'POST',
        params: {
            memberId: mid,
            action: 'destroy',
            module: 'participant',
            eventId: eid
        },
        success: function(o, success, response){
        
            var or = Ext.decode(o.responseText);
            
            if (or.success == true) {
                Ext.MessageBox.alert('Full On Sport', 'Participant deleted successfully');
                FOS.Organiser.Event.Participant.refresh(false);
            }
            else {
                Ext.MessageBox.alert('Full On Sport', 'Participant deletion failed!'); 
                
            }
			if (Ext.get('participantDetail'))
				Ext.get('participantDetail').unmask();
        },
		failure: function(response, options){
            if (Ext.get('participantDetail'))
				Ext.get('participantDetail').unmask();
            Ext.Msg.alert('Failed', response.status);
            
        }
    });
    
    
};

FOS.Organiser.Event.Participant.Detail.save = function(){

    if (Ext.getCmp('participantDetail').getForm().isValid() == false) {
        Ext.MessageBox.alert('Full On Sport', 'You have not completed filling out the form. See warning messages for details.');
        return false;
        
    }
    
    Ext.get('participantDetail').mask('Saving participant detail. Please wait...', 'x-mask-loading');
    
    if (FOS.Organiser.Event.Participant.Detail.isMember == true && FOS.Organiser.Event.Participant.Detail.isEntered == true) {
        action = 'update';
        
    }
    else 
        if (FOS.Organiser.Event.Participant.Detail.isMember == true && FOS.Organiser.Event.Participant.Detail.isEntered == false) {
            action = 'add';
            
        }
        else 
            action = 'create';
    
    if ( Ext.getCmp('club').getValue() == '')
     var  selectedClubId =  42;
     else
     var selectedClubId =   Ext.getCmp('club').getValue();
    
    Ext.Ajax.request({
        url: 'action.php',
        params: {
            module: 'participant',
            action: action,
            eventId: Ext.getCmp('selectedEventId1').getValue(),
            memberId: Ext.getCmp('memberId').getValue(),
			epId: Ext.getCmp('epId').getValue(),
            email: Ext.getCmp('email').getValue(),
            firstname: Ext.getCmp('firstname').getValue(),
            lastname: Ext.getCmp('lastname').getValue(),
            dob: Ext.getCmp('dob').getValue(),
            gender: Ext.getCmp('gender').getValue(),
            raceNo: Ext.getCmp('raceNo').getValue(),
            
		 
            address1: Ext.getCmp('address1').getValue(),
            address2: Ext.getCmp('address2').getValue(),
            address3: Ext.getCmp('address3').getValue(),
            
            region: Ext.getCmp('region').getValue(),
            city: Ext.getCmp('city').getValue(),
            country: Ext.getCmp('country').getValue(),
            postcode: Ext.getCmp('postcode').getValue(),
            emergencyContactNo: Ext.getCmp('emergencyContactNo').getValue(),
            emergencyContactName: Ext.getCmp('emergencyContactName').getValue(),
            
            btfNo: Ext.getCmp('btfNo').getValue(),
            ukAthleticsNo: Ext.getCmp('ukAthleticsNo').getValue(),
            clubId: selectedClubId,
            
            createNewClub: Ext.getCmp('createNewClub').getValue(),
            newClubName: Ext.getCmp('newClubName').getValue(),
            
            homeNo: Ext.getCmp('homeNo').getValue(),
            mobileNo: Ext.getCmp('mobileNo').getValue(),
            medicalInformation: FOS.util.cleanseHTML(Ext.getCmp('medicalInformation').getValue()),
            otherInformation: FOS.util.cleanseHTML(Ext.getCmp('otherInformation').getValue()),
            swimTime: Ext.getCmp('swimTime').getValue(),
            bikeTime: Ext.getCmp('bikeTime').getValue(),
            runTime: Ext.getCmp('runTime').getValue(),
            entryPaid: Ext.getCmp('entryPaid').getValue(),
          
            waveNumber: Ext.getCmp('waveNumber').getValue(),
            positionNumber: Ext.getCmp('positionNumber').getValue(),
            laneNumber: Ext.getCmp('laneNumber').getValue(),
            
            
             
            
            organiserOwned: 1
        
        },
        success: function(response, options){
        
            
            
            var result = Ext.decode(response.responseText);
            
            if (result.success == true) {
			
				Ext.get('participantDetail').unmask();
			
				if (FOS.Organiser.Event.Participant.Detail.createNewAfterSave) {
					FOS.Organiser.Event.Participant.Detail.clear();
					FOS.Organiser.Event.Participant.refresh(false);
				}
				else {
					
					Ext.MessageBox.alert('Full On Sport', 'Save complete.'); 
					location.href = "?module=organiser";
					//FOS.Organiser.Dashboard.show();
					//FOS.Organiser.Event.Participant.refresh(false);
				}
				
				Ext.MessageBox.alert('Full On Sport', 'Save complete.'); 
				
			}
			
			else {
				Ext.get('participantDetail').unmask();
				Ext.Msg.alert('Failed', response.errorMsg);
				
			}
            
			
            
        },
        failure: function(response, options){
            Ext.get('participantDetail').unmask();
            Ext.Msg.alert('Failed', response.status);
            
        }
    });
    
};
FOS.Organiser.Event.Participant.Detail.clear = function(){
     
    
    FOS.Organiser.Event.Participant.Detail.isMember = false;
    FOS.Organiser.Event.Participant.Detail.isEntered = false;
	
	Ext.getCmp('participantDetail').getForm().reset();
	
    FOS.Organiser.Event.Participant.Detail.focus();
};


FOS.Organiser.Event.Participant.Detail.displayFormData = function(data){

    Ext.getCmp('memberId').setValue(data[0].member_id);
	Ext.getCmp('selectedEventId1').setValue(data[0].event_id);
	
	
	 Ext.getCmp('epId').setValue(data[0].ep_id);
    Ext.getCmp('email').setValue(data[0].email);
    Ext.getCmp('firstname').setValue(data[0].firstname);
    Ext.getCmp('lastname').setValue(data[0].lastname);
    Ext.getCmp('gender').setValue(data[0].gender);
    Ext.getCmp('dob').setValue(data[0].dob);
    Ext.getCmp('raceNo').setValue(data[0].race_number);
    Ext.getCmp('selectedEventId1').setValue(data[0].event_id);
    Ext.getCmp('club').setValue(data[0].club_id, true);
    Ext.getCmp('address1').setValue(data[0].address_1);
    Ext.getCmp('address2').setValue(data[0].address_2);
    Ext.getCmp('address3').setValue(data[0].address_3);
    Ext.getCmp('region').setValue(data[0].region_id);
    Ext.getCmp('city').setValue(data[0].city);
    Ext.getCmp('postcode').setValue(data[0].postcode);
    Ext.getCmp('country').setValue(data[0].country_id);
    
    Ext.getCmp('btfNo').setValue(data[0].btf_no);
    Ext.getCmp('ukAthleticsNo').setValue(data[0].uk_athletics_no);
    Ext.getCmp('medicalInformation').setValue(data[0].medical_information);
    Ext.getCmp('otherInformation').setValue(data[0].other_information);
    
    Ext.getCmp('emergencyContactNo').setValue(data[0].emergency_contact_no);
    
    Ext.getCmp('emergencyContactName').setValue(data[0].emergency_contact_name);
    Ext.getCmp('homeNo').setValue(data[0].home_no);
    Ext.getCmp('mobileNo').setValue(data[0].mobile_no);
    
    Ext.getCmp('entryPaid').setValue(data[0].entry_paid);
    Ext.getCmp('swimTime').setValue(data[0].swim_time);
    Ext.getCmp('bikeTime').setValue(data[0].bike_time);
    Ext.getCmp('runTime').setValue(data[0].run_time);
    
    Ext.getCmp('waveNumber').setValue(data[0].wave_number);
    Ext.getCmp('positionNumber').setValue(data[0].position_number);
    Ext.getCmp('laneNumber').setValue(data[0].lane_number);
    
    FOS.Organiser.Event.Participant.Detail.isEntered = true;
	
	FOS.Organiser.Event.Participant.Detail.focus();
};

FOS.Organiser.Event.Participant.Detail.focus = function(ctl) {
	if (ctl)
		Ext.getCmp(ctl).focus();
	 
};


FOS.Organiser.Event.Participant.Detail.show = function( ){

	try {
		
		
		
		
		if (FOS.Organiser.Event.Participant.Detail.view) 
			FOS.Organiser.Event.Participant.Detail.view.destroy();
			
		FOS.Organiser.Event.store.load();
		
		FOS.Organiser.Event.Participant.Detail.clubStore.load();
		
		 FOS.Organiser.Event.view = new Ext.Panel (FOS.Organiser.Event.Participant.Detail.viewConfig);
		   
	 
	 
	 	FOS.Organiser.Event.Participant.Detail.isMember = false;
		FOS.Organiser.Event.Participant.Detail.isEntered = false;
	 	FOS.Organiser.Event.Participant.Detail.focus();
		
	 



	}
	catch (e) {}
	
    
};
    

