var Wick = Wick || {};
Wick.User = (function(){
  function isLoggedIn() {
    return localStorage.isLoggedin === 'true';
  }

  function login() {
    localStorage.isLoggedin = true;
  }

  function logout() {
    localStorage.isLoggedin = false;
  }

  function bindEvents() {
    $('.link-logout').on('click', logout);
  }

  function setLoginState() {
    $('body').attr('data-is-logged-in', isLoggedIn());
  }

  var init = function () {
    bindEvents();
    setLoginState();
  };

  init();

  return {
    login: function(){
      login();
      setLoginState();
    },
    logout: function(){
      logout();
      setLoginState();
    },
    isLoggedIn: isLoggedIn
  };
})();
