
var storeCompany;
var storeGroup;

Ext.onReady(function(){

	Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'side';
    /*
     * ================  Login form  =======================
     */
    show_login();

});
function show_login()
{
var login = new Ext.FormPanel({
	ctCls: 'loginForm',
	//url:racine_site+'/j_spring_security_check', 
	//standardSubmit  :true,
    labelWidth: 80, // label settings here cascade unless overridden
    frame:true,
    title: 'Connexion - Collaborateur AtoutFiat',
    //bodyStyle:'padding:5px 5px 0',
    //height:180,
    width: 300,
    //defaults: {width: 230},
    defaultType: 'textfield',
	monitorValid:true, 
	reader: new Ext.data.DataReader(),
    items: [{
            fieldLabel: 'Email',
            name: 'j_username',
			id:'j_username',
			vtype:'email',
            allowBlank:false,
            emptyText :'Email',
            width : 180,
            maxLength : 120,
			listeners:{
                specialkey:function(f,o){
                    if(o.getKey()==13){
                        submitLogin();
                    }
            	}
        	}
        },{
            fieldLabel: 'Password',
            width : 180,
            name: 'j_password',
			id: 'j_password',
			inputType: 'password',
			allowBlank:false,
			maxLength : 11,
			listeners:{
                specialkey:function(f,o){
                    if(o.getKey()==13){
                        submitLogin();
                    }
            	}
        	} 
        },
        {
        	xtype:'checkbox',
        	id:'_spring_security_remember_me',
        	name:'_spring_security_remember_me',
        	boxLabel:'Se souvenir de moi'
        },
        {
			xtype:'hidden',
			id: 'ctl',
			name: 'ctl',
			value: 'Login'
		}
    ]
});


function submitLogin(){
	
	window.location.replace(racine_site+'/j_spring_security_check?ctl=Login&j_password='+Ext.getCmp('j_password').getValue()+'&j_username='+Ext.getCmp('j_username').getValue()+'&_spring_security_remember_me='+Ext.getCmp('_spring_security_remember_me').checked);
	/*login.getForm().submit(
	{
			url:racine_site+'/j_spring_security_check', 
			waitTitle:'Connecting', 
	        waitMsg:'Sending data...'
	        	,	
	        success: function(form, action) {
	        	window.location = racine_site+"/collaborator/index.html";
			},
			failure:function(form, action){ 
				window.location = racine_site+"/collaborator/index.html";
			}
	});*/
}
/*var submit = login.addButton(
    );*/

var win = new Ext.Window({
    layout:'fit',
    id:'login-win',
    width:325,
    height: 180,
    closable: false,
    resizable: true,
    plain: true,
    items: [login],
    bbar:[{
        text: 'Créer un compte',
        disabled:false,
        cls:'buttonfond',
        handler: function(){
           	createCompte();
        }
    }, '-',  {
      text: 'Mot de passe oublié',
      disabled:false,
      cls:'buttonfond',
      handler: function(){
			Ext.Msg.prompt('Mot de passe oublié', 'Veuillez saisir votre adresse email :', function(btn, text) {
				if (btn == 'ok') {
					UserService.lostPassword(text, function() {
						Ext.Msg.alert('Mail envoyé', 'Un mail contenant vos identifiants vous a été envoyé. A bientôt sur www.atoutfiat.fr.')
					});
				}
			});	
      }
    },'->', {
        text: 'Valider',
        disabled:false,cls:'buttonfond',
        handler: function(){
           	submitLogin();
        }
    }
    ]
});

win.show();

}

function createCompte()
{
	Ext.getCmp('login-win').close();
	
	 var win = new Ext.Window({
	        layout:'fit',
	        id:'passColabo-win',
	        width:345,
	        height: 120,
	        closable: false,
	        resizable: true,
	        plain: true,
	        items: [{
	        		
	        		xtype:'form',
	                labelWidth: 110, // label settings here cascade unless overridden
	                frame:true,
	                title: 'Création de compte - Collaborateur AtoutFiat',
	                //bodyStyle:'padding:5px 5px 0',
	                //height:180,
	                width: 320,
	               
	                //defaults: {width: 230},
	                defaultType: 'textfield',
	        		//monitorValid:true, 
	        		//reader: new Ext.data.DataReader(),
	                items: [
		                {
		                	id:'motDePassGroup',
		                	fieldLabel:'Mot de passe groupe',
		                	minLength:2,
		                	emptyText:'Saisie du mot de passe Groupe',
		                	width:170
		                }]
		           }
	        ],
	        bbar:[ {
		        text: 'Annuler',
		        disabled:false,cls:'buttonfond',
		        handler: function(){
	        		show_login();
	        		Ext.getCmp('passColabo-win').close();
		        }
	        },'->',
	    
	          {
		        text: 'Valider',
		        disabled:false,cls:'buttonfond',
		        handler: function(){
		           	submitPassColabo();
		        }
	        }
	        ]
		});
	    
		win.show();

}

function submitPassColabo(){
	 var onload = Ext.getCmp('passColabo-win');
		if (onload)
			{onload.getEl().mask('Chargement', 'x-mask-loading');}

		UserService.checkSignInGroupPassword(
				Ext.getCmp('motDePassGroup').getValue(),
				{callback: submitPassColabo_ok, errorHandler: motDePassGroup_dwrErreur}
		
		);
	
}

var status_profil;
function submitPassColabo_ok(store)
{
	status_profil=store;
	Ext.getCmp('passColabo-win').close();
	
	    var  win = new Ext.Window({
	            id: 'CreateProfil-win',
	            title:WIN_MYPROFIL,
	            width:485,
	            height:580,
	            resizable:true,
	            maximizable:false,
	            iconCls: 'icon-myProfil',
	            shim:false,
	            animCollapse:false,
	            constrainHeader:true,
	           
	          
	            items: [
	            		{
	            			region:'center',
	            			items: [{
	            				xType:'panel',
	            			    layout:'table',
	            			    baseCls: 'x-plain',
	            			    width:440,
	            			    cls:'decalage_gauche_10px',
	            			    layoutConfig: {
	            			        columns:1
	            			    },
	            			    items:[{
	            			        // Fieldset in Column 1

	            			        xtype:'fieldset',
	            			        width:415,
	            			        title: 'Identité',
	            			        collapsible: false,
	            			        autoHeight:true,
	            			        cls:'fieldset_sous_menu',
	            			        
	            			        items :[
	            			                {
	            			                	xtype:'panel',
	            			                	layout:'column',
	            			                	ctCls:'color_text',
	            			                	items:[
	            			                	       {
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Civilité'
	            			                	       },
	            			                	       {
	            			                	    	   xtype:'panel',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   layout:'column',
	            			                	    	   layoutConfig: {
	            			               			        columns:3
	            			               			    	},
	            			                	    	   items:[
		            			                	       {
		            			                				xtype:'radio',
		            			                				boxLabel:'Mr',
		            			                				checked: false,
		            			                				name:"radio_civiliter",
		            			                				id:"radio_civiliter_mr",
		            			                				inputValue:"0",
		            			                				height:22
		            			                			},
		            			                	       {
		            			                				xtype:'radio',
		            			                				boxLabel:'Mme',
		            			                				checked: false,
		            			                				name:"radio_civiliter",
		            			                				id:"radio_civiliter_mme",
		            			                				inputValue:"1",
		            			                				height:22,
		            			                				cls:'margin_gauche_10px'
		            			                			},
		            			                	       {
		            			                				xtype:'radio',
		            			                				boxLabel:'Mlle',
		            			                				checked: false,
		            			                				name:"radio_civiliter",
		            			                				id:"radio_civiliter_mlle",
		            			                				inputValue:"2",
		            			                				height:22,
		            			                				cls:'margin_gauche_10px'
		            			                			}
		            			                			]
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Nom'
	            			                	    	   
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_lastname',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:'',
	            			                	    	   minLength:3
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Prénom'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_firstname',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:'',
	            			                	    	   minLength:3
	            			                	    		   
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Fonction'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_post',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:''
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Groupe'
	            			                	       },{
	            			                	    	   xtype:'combo',
	            			                	    	   editable:false,
	            			                	    	   id:'myProfil_groups',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   typeAhead: true,
	            			                	    	    triggerAction: 'all',
	            			                	    	    lazyRender:true,
	            			                	    	    mode: 'local',
	            			                	    	    store:storeGroup,
	            			                	    	    valueField: 'id',
	            			                	    	    displayField: 'name'
	            			                	    	    

	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Société'
	            			                	       },{
	            			                	    	   xtype:'combo',
	            			                	    	   editable:false,
	            			                	    	   columnWidth: 0.6,
	            			                	    	   typeAhead: true,
	            			                	    	    triggerAction: 'all',
	            			                	    	    lazyRender:true,
	            			                	    	    mode: 'local',
	            			                	    	    id:'myProfil_Compagny',
	            			                	    	    store:storeCompany,
	            			                	    	    valueField: 'id',
	            			                	    	    displayField: 'corporatename'

	            			                	       },
	            			                	       {
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Retraité'
	            			                	       },
	            			                	       {
	            			                	    	   xtype:'panel',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   layout:'column',
	            			                	    	   layoutConfig: {
	            			               			        columns:2
	            			               			    	},
	            			                	    	   items:[
		            			                	       {
		            			                				xtype:'radio',
		            			                				boxLabel:'oui',
		            			                				checked: false,
		            			                				name:"radio_retraite",
		            			                				id:"radio_retraite_oui",
		            			                				inputValue:"0",
		            			                				height:22
		            			                			},
		            			                	       {
		            			                				xtype:'radio',
		            			                				boxLabel:'non',
		            			                				checked: false,
		            			                				name:"radio_retraite",
		            			                				id:"radio_retraite_non",
		            			                				inputValue:"1",
		            			                				height:22,
		            			                				cls:'margin_gauche_10px'
		            			                			}
		            			                			]
	            			                	       }
	            			                	       ]
	            			                }]
	            			    },
				                {
	            			        // Fieldset 2

	            			        xtype:'fieldset',
	            			        width:415,
	            			        title: 'Coordonnées',
	            			        collapsible: false,
	            			        autoHeight:true,
	            			        cls:'fieldset_sous_menu',
	            			        
	            			        items :[
	            			                {
	            			                	xtype:'panel',
	            			                	layout:'column',
	            			                	ctCls:'color_text',
	            			                	items:[
	            			                	       {
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'E-mail'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_email',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:'',
	            			                	    	   vtype:'email',
	            			                	    	   listeners: {
	            			                	    	   		'blur': function(field) {
	            			                	    	   			UserService.checkMailUniqueness(field.getValue(), function (result) {
		            			                	    	   			if (result > 0) {
		            			                	    	   				Ext.Msg.alert('Mail déjà utilisé', 'Ce mail semble déjà utilisé. Veuillez vous assurer que vous n\'avez pas déjà créé un compte ou contactez un administrateur (ventescollaborateurs@fiat.com).');
		            			                	    	   				Ext.getCmp('myProfil_email').setValue('');
		            			                	    	   			}
	            			                	    	   			});
	            			                	       			}
	            			                	       		}
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Confirmation e-mail'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_Cemail',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:'',
	            			                	    	   vtype:'email'
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Tél. Fixe'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_prophone',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:''
	            			                	    		   
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Tél. Portable'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_gsmphone',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:''
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Adresse'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_address',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:''
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Code Postal'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_zip',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:''
	            			                	       },{
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Ville'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_town',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:''
	            			                	       }]
	            			                }]
	            			         
	            			    },
				                {
	            			        // Fieldset 2

	            			        xtype:'fieldset',
	            			        width:415,
	            			        title: 'Mots de passe',
	            			        collapsible: false,
	            			        autoHeight:true,
	            			        cls:'fieldset_sous_menu',
	            			        
	            			        items :[
	            			                {
	            			                	xtype:'panel',
	            			                	layout:'column',
	            			                	ctCls:'color_text',
	            			                	items:[
	            			                	       {
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Mot de passe :'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_pass',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:'',
	            			                	    	   inputType:'password'
	            			                	       }, {
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.4,
	            			                	    	   text:'Confirmation :'
	            			                	       },{
	            			                	    	   xtype:'textfield',
	            			                	    	   id:'myProfil_Cpass',
	            			                	    	   columnWidth: 0.6,
	            			                	    	   value:'',
	            			                	    	   inputType:'password'
	            			                	       },/*
	            			                	       {
	            			                	    	   xtype:'label',
	            			                	    	   columnWidth: 0.5,
	            			                	    	   text:'Validation du cnil ?'
	            			                	       },
	            			                	       {
	            			                	    	   xtype:'panel',
	            			                	    	   columnWidth: 0.5,
	            			                	    	   layout:'column',
	            			                	    	   layoutConfig: {
	            			               			        columns:2
	            			               			    	},
	            			                	    	   items:[
		            			                	       {
		            			                				xtype:'radio',
		            			                				boxLabel:'oui',
		            			                				checked: false,
		            			                				name:"radio_cnil",
		            			                				id:"radio_cnil_oui",
		            			                				inputValue:"0",
		            			                				height:22
		            			                			},
		            			                	       {
		            			                				xtype:'radio',
		            			                				boxLabel:'non',
		            			                				checked: false,
		            			                				name:"radio_cnil",
		            			                				id:"radio_cnil_non",
		            			                				inputValue:"1",
		            			                				height:22,
		            			                				cls:'margin_gauche_10px'
		            			                			}
		            			                			]
	            			                	       },*/{
	            			                	    	   xtype:'label',
	            			                	    	   cls:'font_size_10px',
	            			                	    	   columnWidth: 1,
	            			                	    	   text:'Vous disposez d\'un droit d\'accès, de modification, de rectification et de suppression des données qui vous concernent (art. 34 de la loi "Informatique et Libertés"). Pour l\'exercer, adressez vous à Fiat Auto France S.A. - Service Collaborateur - Atoufiat - CNIL - 6 rue Nicolas Copernic - 78 TRAPPES.'
	            			                	       }]
	            			                }]
	            			         
	            			    }
	            			    
				            			           
	            			           
	            			  ]
	            			}]     
	            		}],
	            		bbar:['->',{
        			    	xtype:'button',
        			    	text:'Sauvegarder',
        			    	cls:'buttonfond',
        			    	handler :function(b,e){sauvegard_profil();}

        			    }]
	    	});
	    
	    win.show();
	    recupGroups();
	    Ext.getCmp('myProfil_groups').on('close',function(){show_login();});
	    Ext.getCmp('CreateProfil-win').on('close',function(){show_login();});
	    Ext.getCmp('myProfil_groups').on('select',function(combo,record, index ){change_CreateProfil_groups(index);});
	    Ext.getCmp('myProfil_Compagny').on('expand', function(){Ext.getCmp('myProfil_Compagny').store.filter('status', 1, true, true);});
}

function recupGroups(){GroupService.getAjaxGroupsByCategoryId(status_profil, false, recupGroups2);}

function recupGroups2(store){
	
	storeGroup.loadData(store);
	//storeGroup.sort('name');
}


function sauvegard_profil(){
	
	if (Ext.getCmp("myProfil_lastname").getValue() == "")
		Ext.Msg.alert('alert','Veuillez indiquer votre nom.');
	else if (Ext.getCmp("myProfil_firstname").getValue() == "")
		Ext.Msg.alert('alert','Veuillez indiquer votre prénom.');
	else if (Ext.getCmp('myProfil_email').getValue()!= Ext.getCmp('myProfil_Cemail').getValue() )
		Ext.Msg.alert('alert','Les deux emails saisis sont différents.');
	else if (Ext.getCmp('myProfil_email').getValue() == "")
		Ext.Msg.alert('alert','Veuillez saisir une adresse mail.');
	else if (Ext.getCmp('myProfil_pass').getValue()!= Ext.getCmp('myProfil_Cpass').getValue() )
		Ext.Msg.alert('alert','Les deux mots de passe saisis sont différents.');
	else if (!Ext.getCmp("myProfil_email").validate() || Ext.getCmp("myProfil_email").getValue() == "")
		Ext.Msg.alert('alert','Votre email ne semble pas valide.');
	else if (!Ext.getCmp("myProfil_firstname").validate())
		Ext.Msg.alert('alert','Votre nom contient des caractères qui ne semblent pas valides.');
	else if (!Ext.getCmp("myProfil_lastname").validate())
		Ext.Msg.alert('alert','Votre prénom contient des caractères qui ne semblent pas valides.');
	else if (Ext.getCmp("myProfil_prophone").getValue() == "" && Ext.getCmp("myProfil_gsmphone").getValue() == "")
		Ext.Msg.alert('alert','Vous devez renseigner au moins un numéro de téléphone.');
	else if (Ext.getCmp("myProfil_prophone").getValue() == "" && Ext.getCmp("myProfil_gsmphone").getValue() == "")
		Ext.Msg.alert('alert','Vous devez renseigner au moins un numéro de téléphone.');
	else if (Ext.getCmp("myProfil_address").getValue() == "")
		Ext.Msg.alert('alert','Veuillez indiquer votre adresse.');
	else if (Ext.getCmp("myProfil_zip").getValue() == "")
		Ext.Msg.alert('alert','Veuillez indiquer un code postal.');
	else if (Ext.getCmp("myProfil_town").getValue() == "")
		Ext.Msg.alert('alert','Veuillez indiquer le nom de votre ville.');
	else if (Ext.getCmp("myProfil_Compagny").getValue() == "-1")
		Ext.Msg.alert('alert','Veuillez choisir une société.');
//	else if(Ext.getCmp('radio_cnil_oui').getValue()==false)
//		Ext.Msg.alert('alert','Vous devez valider le cnil.');
	else
	{
	
	
		storeProfilNewUser.id			= null;
		storeProfilNewUser.firstname	= Ext.getCmp("myProfil_firstname").getValue();
		storeProfilNewUser.lastname		= Ext.getCmp("myProfil_lastname").getValue();
		storeProfilNewUser.login		= Ext.getCmp("myProfil_email").getValue();
		storeProfilNewUser.passwd		= Ext.getCmp("myProfil_pass").getValue();
		storeProfilNewUser.email		= Ext.getCmp("myProfil_email").getValue();
		
		if(Ext.getCmp('radio_civiliter_mr').getValue()==true){storeProfilNewUser.civility=0;}
		if(Ext.getCmp('radio_civiliter_mme').getValue()==true){storeProfilNewUser.civility=1;}
		if(Ext.getCmp('radio_civiliter_mlle').getValue()==true){storeProfilNewUser.civility=2;}
		
		storeProfilNewUser.post			= Ext.getCmp("myProfil_post").getValue();
		storeProfilNewUser.prophone		= Ext.getCmp("myProfil_prophone").getValue();
		storeProfilNewUser.gsmphone		= Ext.getCmp("myProfil_gsmphone").getValue();
		storeProfilNewUser.address		= Ext.getCmp("myProfil_address").getValue();
		storeProfilNewUser.zip			= Ext.getCmp("myProfil_zip").getValue();
		storeProfilNewUser.town			= Ext.getCmp("myProfil_town").getValue();
		
	
		if (Ext.getCmp('radio_retraite_oui').getValue==true)
			storeProfilNewUser.pensioner=true;
		else
			storeProfilNewUser.pensioner=false;
		
		
		storeProfilNewUser.groupId		= Ext.getCmp("myProfil_groups").getValue();
		storeProfilNewUser.companyId	= Ext.getCmp("myProfil_Compagny").getValue();
		storeProfilNewUser.record		= new Date();
		storeProfilNewUser.lastlogin	= new Date();
		storeProfilNewUser.status		= 1;
		storeProfilNewUser.etype		= "ROLE_COLLABORATOR";
		storeProfilNewUser.cnil			= 0;
		
		
		
		//storeProfilNewUser.id		= Ext.getCmp("myProfil_address").getValue();
		
		UserService.saveNewUser(storeProfilNewUser,sauvegard_profil2);
	}
}


function sauvegard_profil2(store)
{
	Ext.Msg.show({
		   title:'Inscription réussie',
		   msg: 'Votre compte a bien été créé. Un mail de confirmation vous a été envoyé.',
		   buttons: {ok: "Fermer"},
		   fn: function() {
			   Ext.getCmp('CreateProfil-win').close();
			   show_login();
			}
	});
}



function change_CreateProfil_groups(index){
	var onload = Ext.getCmp('CreateProfil-win');
	if (onload)
		onload.getEl().mask('Chargement', 'x-mask-loading');

	CompanyService.getAjaxCompaniesFromGroupId(Ext.getCmp('myProfil_groups').getValue(),change_CreateProfil_groups2);
}

function change_CreateProfil_groups2(store)
{
	
	Ext.getCmp('myProfil_Compagny').store.loadData(store);
	
	var rec = new storeCompany.recordType({id:-1, corporatename:'Sélectionnez une société'});
	rec.commit();
	Ext.getCmp('myProfil_Compagny').store.insert(0,rec);

	if (Ext.getCmp('myProfil_Compagny').store.data.length > 0) {
		Ext.getCmp('myProfil_Compagny').setValue(-1);
	} else {
		Ext.getCmp('myProfil_Compagny').store.removeAll();
		Ext.getCmp('myProfil_Compagny').setValue("");
	}

	var onload = Ext.getCmp('CreateProfil-win');
	if (onload)
		onload.getEl().unmask();
}


function motDePassGroup_dwrErreur(message,expt)
{
	Ext.Msg.alert('Erreur',message);
	var onload = Ext.getCmp('passColabo-win');
	if (onload)
		{onload.getEl().unmask();}
}
