/*
* AuthorizationFormController
* -----------------------
* @author        : Filatov Dmitry <alpha@design.ru>
* @last_modified : 14.12.2007
*/

function AuthorizationFormController(
	oForm,
	oParams
	) {

	this.oPopup = null;
	this.oAnimationController = new AnimationController(30);

	AuthorizationFormController.baseConstructor.call(
		this,
		oForm,
		oParams
		);

}

AuthorizationFormController.inheritFrom(
	FormController,
	{

		init : function() {

			this.oPopup = new Popup(this.oParams.oElementPopup);

			var oThis = this;

			new ActionButton(
				this.oParams.oElementOpen,
				[
					{
						fHandler : function() {

							oThis.showPopup();

							return true;

						}
					}
				]
				);

		},

		showPopup : function() {

			if(this.oPopup.isOpened()) {
				return this.oPopup.close();
			}

			this.oPopup.oElement.style.top = '-20em';

			this.oPopup.open();

			this.oForm.getWidgetById('username').focus();

			this.oAnimationController.addAnimation(
				new AnimationEquation(
					this.oPopup.oElement,
					{
						aProperties  : ['top'],
						aUnits       : ['em'],
						aValuesStart : [-20],
						aValuesEnd   : [2.2],
						iFramesCoun  : 50,
						aEquations   : [AnimationEquation.Cubic.easeOut]						
					}
					)
				);

			this.oAnimationController.start();


		}

	}

);