ccip.fdgp.IdentificationLdForm = Ext.extend(Ext.form.FormPanel, {
	
	// Initialisation
	initComponent: function() 
	{
	
		var form = this;	    
	    

	    // Configuration
	    Ext.apply(this, {
	    	standardSubmit: true,	    	 
	        frame:true,
	        cls: 'x-custom-grid',
	        width:430,
	        height:220,
	        defaultType: 'textfield',
	        closable:false,
		    header: false,
			draggable:false,
			hideBorders:true,
			bodyBorder:false,
		    resizable: false,
		    border: false,
	        
	        
			items: [{
			    	id:         'siretTextField-id',
	            	fieldLabel: 'SIRET ',
	                name:       'siret',
	                maxLength: 14,
	                width: 290,
	                tabIndex: 1
	            },
				{
			    	id:         'mdpTextField-id',
	            	fieldLabel: 'MOT DE PASSE ',
	                name:       'nomUsage',
	                inputType: 'password',
	                width: 290,
	                tabIndex: 4
	            }
	        ],
	        cls: 'x-custom-grid',
			bbar:[
				{xtype: 'tbfill'},
				{
					xtype:'button',
					iconCls:'x-custom-icon-fleche',
					disabled:true,
					scope:   this
				},{
					xtype:'button',
					iconCls:'x-custom-icon-valider',
					scope:   this,
					handler: this.validate
			}],
            buttonAlign:'center',	
			tbar:[
				{xtype: 'tbfill'},
				{
					xtype:'button',
					iconCls:'x-custom-icon-fleche',
					disabled:true,
					scope:   this
				},{
					xtype:'button',
					iconCls:'x-custom-icon-valider',
					scope:   this,
					handler: this.validate
			}]
	    });
	    
	    // TODO : ça ne marche pas !!!
	    // Ext.getCmp('fonctionComboBox-id').setValue(Ext.get(form.params.codeFonction).getValue());
	    
	    // Appel de la classe mère
	    ccip.fdgp.IdentificationLdForm.superclass.initComponent.apply(this, arguments);
	},
	
	
	// Action de chargement des données
	load:function() {
	}, // fin de la fonction load
	
	
	// Action sur le bouton Valider
	validate:function() {
		var siret = Ext.getCmp('siretTextField-id').getValue();
		var mdp = Ext.getCmp('mdpTextField-id').getValue();
		var resultat;
		
		if(siret == ""){
			Ext.ux.form.XMessageAlert("Veuillez renseigner le siret.");
		}
		else if(siret.length != 14){
			Ext.ux.form.XMessageAlert("Le numéro de siret doit comporter 14 caractères.");
		}
		else if(mdp == ""){
			Ext.ux.form.XMessageAlert("Veuillez renseigner le mot de passe.");
		}
		else {
			
			

			try {
				LettreDeDesignation.isIdentificationValide(siret, mdp, {callback:function(data) {
					resultat = data;	
				},
				async:false,
				timeout: 10000,
				errorHandler:function(errorString, exception) {
					Ext.ux.form.XMessageAlert(errorString);
				}
				});
			}
			catch(ex) {
				Ext.ux.form.XMessageAlert(ex);
			} 	
 		
			if(resultat){
				alert('identification ok');
			}
			else{
				alert('identification ko');
			}
				
			
			
//		// On enregistre les informations sur le nouveau représentant
//		Ext.getDom("representantTemporaire.fonction.code").value = Ext.getCmp('fonctionComboBox-id').getValue();
//		Ext.getDom("representantTemporaire.civilite").value = Ext.getCmp('civiliteComboBox-id').getValue();
//		Ext.getDom("representantTemporaire.nom").value = nom;
//		Ext.getDom("representantTemporaire.nomUsage").value = nomUsage;
//		Ext.getDom("representantTemporaire.prenom").value = prenom;
//		Ext.getDom("representantTemporaire.service").value = service;
//		Ext.getDom("representantTemporaire.fonctionLibre").value = fonctionLibre;
//		Ext.getDom("representantTemporaire.mail").value = mail;
//		Ext.getDom("representantTemporaire.telephone").value = telephone;
//
//		// On vide la popup
//		//this.reinitialisation();
//		// On cache la popup de saisie d'un représentant
//		Ext.getCmp('representantwin-id').destroy();
//		
//		// On recharge la page
//		Ext.getDom('contact-id').typeSubmit.value = "ajouterRepresentant";
//		Ext.getDom('contact-id').submit();
		}
	}, // fin de la fonction validate
	
    onRender:function() {
        ccip.fdgp.IdentificationLdForm.superclass.onRender.apply(this, arguments);
    }, // eo function onRender
    
	// Action sur le bouton Annuler
	cancel:function() {
		Ext.getCmp('identificationwin-id').destroy();
	}// fin de la fonction cancel
});

Ext.reg('identificationldform', ccip.fdgp.IdentificationLdForm);
