var CabinetAuthorization = {	

	INVISIBLE_CLASS_NAME  : 'invisible',	
			
	oActionQueue           : null,		
	oForm                  : null,
	oLogin                 : null,
	oPassword              : null,
	oSubmit                : null,	

	init : function(
		sControllerUrl,		
		oForm		
		) {							
				
		this.oActionQueue = new	ActionQueue(sControllerUrl);		
		this.oForm = oForm;		
		this.oError = oForm.getElementsByTagName('dd')[2];
		
		this.oForm.getElementsByTagName('form')[0].onsubmit = function() {
			
			CabinetAuthorization.logon();
			
			return false;
			
		};
		
		var aInputs = this.oForm.getElementsByTagName('input');				
		
		this.oLogin = aInputs[0];
		this.oPassword = aInputs[1];
		this.oSubmit = aInputs[2];				
	
	},		
	
	logon : function() {			
	
		var aData = [];
		
		aData['auth-name'] = this.oLogin.value;
		aData['auth-passwd'] = this.oPassword.value;
	
		this.oActionQueue.addAction(
			new Action.instance(
				'auth-logon',
				aData,
				null,
				this,
				'logonOk',
				'logonError'
				)
			);							
			
		this.progress();
		
		this.oActionQueue.process();				
	
	},
	
	displayError : function(bShow) {
	
		bShow? Common.Class.remove(this.oError, this.INVISIBLE_CLASS_NAME) : Common.Class.add(this.oError, this.INVISIBLE_CLASS_NAME);
	
	},
	
	progress : function() {
	
		this.displayError(false);
		this.oSubmit.disabled = true;		
	
	},
	
	unprogress : function() {
	
		this.oSubmit.disabled = false;		
	
	},
	
	logonOk : function(aResult) {			
	
		if(aResult['refresh']) {
			document.location = aResult['refresh'];
		}
	
		this.displayError(false);
	
	},		
	
	logonError : function(sSign, aAddData) {
	
		this.displayError(true);				
		this.unprogress();		
	
	}
	
};