var Signin = Class.create({
  initialize: function() {
    this.loginLink = $('log_in');
    this.loginLink.onclick = $DC(this, this.onLogIn);
    this.form = $('signin_form');
    this.loginInput = $('session_login');
    this.mainSignIn = $('main_signin');
    
    if (this.mainSignIn) {
      this.initMainSignIn();
    }
  },
  
  onLogIn: function() {
    this.form.show();
    this.loginInput.focus();
    this.loginLink.hide();
    
    return false;
  },
  
  initMainSignIn: function() {
    var forms = this.mainSignIn.select('form');
    
    this.mainSignInForm = forms[0];
    this.resetPasswordForm = forms[1];
    this.mainLogin = $('main_login');
    this.reset = $('reset');
    this.cancel = $('cancel');
    
    this.mainLogin.focus();
    this.reset.onclick = $DC(this, this.onReset);
    this.cancel.onclick = $DC(this, this.onCancel);
  },
  
  onReset: function() {
    this.resetPasswordForm.toggle();
    
    return false;
  },
  
  onCancel: function() {
    this.resetPasswordForm.hide();
    
    return false;
  }
});

Event.observe(window, 'load', function() {
  this.signin = new Signin();
});


