function LogoutFormController(settings,rpcClientObject)
{
  this._construct(settings,rpcClientObject);
}
(function(){
  var _this= null;
  
  LogoutFormController.prototype={
  	form: null,
  	formContainer: null,
    pageContainer: null,
    loadingPageContainer: null,
    
    
    data: {
      onLogout: ''
    },
    
    logoutBtn: null,
  	
    Events: {
    },

    addEventListener: function(customEvent,listener)
    {
      if (typeof(_this.eventListeners[customEvent])=='undefined')
        _this.eventListeners[customEvent]=[];
        
      _this.eventListeners[customEvent].push(listener);
      return false;
    },
    
    notifyListeners: function(evt,customEvent,customData)
    {
    	if (typeof(_this.eventListeners)=='undefined' || typeof(_this.eventListeners[customEvent])=='undefined')
    		return;
    	var i=0;
    	for (i=0;i<_this.eventListeners[customEvent].length;i++)
    	{
    		_this.eventListeners[customEvent][i](evt,customData);
    	}
    },
    
  	_construct: function(settings,rpcClientObject)
  	{
  	  _this=this;
  	  _this.rpcClientObject=rpcClientObject;
  	
  		if (typeof(settings)!='undefined')
  		{
  		  if (typeof(settings.formName)!='undefined') _this.form=document.forms[settings.formName];
  		  if (typeof(settings.formContainerId)!='undefined'){ 
          var tmpEffect=new Spry.Effect.Fade(settings.formContainerId, {duration: 2000, toggle: false});
          tmpEffect.start();
        }
  		  
  		  if (typeof(settings.logoutBtnId)!='undefined'){ 
          Spry.Utils.addEventListener(settings.logoutBtnId,'click',_this.onLogoutBtn);
          _this.logoutBtn=document.getElementById(settings.logoutBtnId);
        }
  		  if (typeof(settings.onLogout)!='undefined') _this.data.onLogout=settings.onLogout;
          
          // H //
        if (typeof(settings.PageContainer)!='undefined'){
          _this.showPageContainer=new Spry.Effect.Blind(settings.PageContainer, {duration: 500, from: '0%', to: '100%', toggle: false});
          _this.hidePageContainer=new Spry.Effect.Blind(settings.PageContainer, {duration: 500, from: '100%', to: '0%', toggle: false});
          //_this.hidePageContainer.start();
        }
        
        if (typeof(settings.loadingPageContainer)!='undefined'){
          _this.showLoadingPageContainer=new Spry.Effect.Blind(settings.loadingPageContainer, {duration: 100, from: '0%', to: '100%', toggle: false});
          _this.hideLoadingPageContainer=new Spry.Effect.Blind(settings.loadingPageContainer, {duration: 100, from: '100%', to: '0%', toggle: false});
          
        }
                 
  		}
      
      _this.checkStatus();
      //_this.showPage();
      
  	},

    showPage: function()
     {
        _this.hideLoadingPageContainer.start();
        //_this.showPageContainer.start();
        var myPageContainer = document.getElementById('PAGE_CONTAINER');
        myPageContainer.style.display = "block";
        myPageContainer.style.height = "100%";
        //myPageContainer.style.overflow = "visible";
        myPageContainer.style.visibility = "visible";
     },
     hidePage: function()
     {
        
     },
     showPageLoading: function()
     {
     
     },
     hidePageLoading: function()
     {
     
     },
     
    checkStatus: function()
    {
      _this.rpcClientObject.setData(_this.data,_this.checkStatusCallback);
      _this.rpcClientObject.call('controllers_personal_page.checkStatus',5);
      
         
    },
    
    checkStatusCallback: function(response)
    {
      if (response.error)
      {
        //alert(response.error);
        _this.showPage();  
        return;
      }
      
      Spry.Utils.removeClassName(_this.logoutBtn,'hidden');
      _this.showPage();  
    },
    
    onLogoutBtn: function(evt)
    {
      _this.rpcClientObject.setData(_this.data,_this.onDataReady);
      _this.rpcClientObject.call('controllers_login.logout',5);
      evt.preventDefault();
      return false;
    },
      	
    onDataReady: function(response)
    {
      if (response.error)
      {
        //alert(response.error);
        return;
      }
      
      
    }
  }
})();