// Функция logout выход из сайта
// Подключается в файле resources/js/docs.js

function logout(){
	Ext.MessageBox.show({
		title : 'Производится выход...',
		iconCls:'icon-door-out',
		msg : "Удаляются куки...",
		progressText : 'Выполнено на 0%',
		width : 300,
		progress : true, // 1
		closable : false
	});
					
	for(var i=0;i<4;i++){
		(function(i){
			return function(){
				if(i==0){
					
					(function(){
						var percent=i/3+0.1,
						    percentRound=Math.round(percent*100);
							
						var expires=new Date(new Date().getTime()-(1000*60*60*24*30));
							Ext.util.Cookies.set('user_id_session','',expires);
							
						Ext.MessageBox.updateProgress(percent, 'Выполнено на '+percentRound+'%');
					}).defer(700);
					
					(function(){
						var percent=i/3+0.2,
						    percentRound=Math.round(percent*100);
							
						var expires=new Date(new Date().getTime()-(1000*60*60*24*30));
							Ext.util.Cookies.set('user','',expires);
							
						Ext.MessageBox.updateProgress(percent, 'Выполнено на '+percentRound+'%');
					}).defer(1400);	
				}
				if(i==1){								
					Ext.MessageBox.updateProgress(i/3, 'Выполнено на '+30+'%','Деактивация панели...');
					(function(){
						var percent=i/3+0.1,
						    percentRound=Math.round(percent*100);
							Ext.getCmp('button-logout').hide();
							Ext.MessageBox.updateProgress(percent, 'Выполнено на '+percentRound+'%');
					}).defer(700);
									
					(function(){
						var percent=i/3+0.2,
						    percentRound=Math.round(percent*100),
							el=Ext.getCmp('button-user')
							el.hide();
							el.setText('');
							Ext.MessageBox.updateProgress(percent, 'Выполнено на '+percentRound+'%');
					}).defer(1400);
									
				}
				if(i==2){
								
					Ext.MessageBox.updateProgress(i/3, 'Выполнено на '+60+'%','Восстановление настроек...');
								
					(function(){
						var percent=i/3+0.1,
						    percentRound=Math.round(percent*100),
							el=Ext.getCmp('button-registration');										
							el.show();
							Ext.MessageBox.updateProgress(percent, 'Выполнено на '+percentRound+'%');
					}).defer(700);
									
					(function(){
						var percent=i/3+0.2,
						    percentRound=Math.round(percent*100),
							el=Ext.getCmp('button-login');										
							el.show();
							Ext.MessageBox.updateProgress(percent, 'Выполнено на '+percentRound+'%');
						}).defer(1400);
									
				}
				
				if(i==3){
					Ext.MessageBox.updateProgress(i/3, 'Выполнено на '+100+'%','Выход произведен.');
					Ext.MessageBox.hide.defer(2000, Ext.MessageBox);
				}
			}
		})(i).defer(2000*i);
	}
}
