logged_in = false;

function errorAlert(request) {
  alert('ajax error!');
}

function toggle_auth_method(){
 password = $('comment_author_password')
 if ($F('comment_login') == "login") {
	$('comment-form-login').show();
	$('comment-form-anon').hide();
	$('email-replies').show();
	$('comment_author_auth_email').focus();
/*	password.disabled = false;
	password.type = "password"; */
  } else {
	$('comment_anon').checked = true;
	$('comment-form-anon').show();
	$('comment-form-login').hide();
	$('email-replies').hide();
	$('comment_author_name').focus();
/*	password.disabled = true;
	password.type = "text"; */
  } 
/*
//} else if ($F('comment_anon') == "anonymous") {

  } else {
	$('comment-form-login').show()
	$('comment-form-anon').show()
  } */
}

Event.onReady(function() {
  if (font_size = getCookie('font_size')) {
    setActiveStyleSheet('font', font_size);
  }
  if (getCookie('logged_in')) {
    logged_in = true;
    $('account').show();
    $('login').hide();
    $('logout').show();
    cf = $('comment-form-authentication')
    if (cf) {
      cf.hide();
    }
    new Ajax.Request('/account/login_status', { asynchronous: true, evalScripts: true, onFailure: errorAlert });
  } else {
	ca = $('comment_anon')
	if (ca) {
	  toggle_auth_method()
	  new Form.Element.Observer('comment_anon', 0.2, toggle_auth_method);
	  new Form.Element.Observer('comment_login', 0.2, toggle_auth_method);
	}
  }
});
