var ITF = {};


ITF.login = function(data) {
  app.user = data.user;
  var box = app.$ui.loginBox;
  box.slideUp("slow", function() { 
    box.$loginBtn.hide();
    box.$registerBtn.hide();
    box.$info.html("logged in as " + data.user.username + " ");
    box.$logoutBtn.show();
    box.slideDown();
  });
}

ITF.logout = function(data) {
  app.user = data.user;
  var box = app.$ui.loginBox;    
  box.slideUp("slow", function() {
    box.$logoutBtn.hide();
    box.$info.html('');
    box.$loginBtn.show();
    box.$registerBtn.show();
    box.slideDown();
  });
//    alert("logged out");
}

ITF.setSizes = function() {
  var mp = app.$ui.middlePanel;
  var winHeight = parseInt(mp.height());
  var winWidth = parseInt(mp.width());
  var panelHeight = parseInt(winHeight / 3);
  var panelWidth = parseInt(winWidth / 3);
  mp.size(0, panelHeight);
  mp.size(2, panelHeight);  
  mtp = app.$ui.middleTopPanel;
  mmp = app.$ui.middleMiddlePanel;
  mbp = app.$ui.middleBottomPanel;
  mtp.size(0, panelWidth);
  mtp.size(2, panelWidth);
  mmp.size(0, panelWidth);
  mmp.size(2, panelWidth);
  mbp.size(0, panelWidth);
  mbp.size(2, panelWidth);

  //FIXME: FIX!
  var listHeight = panelHeight - 22;
  app.$ui.bestpracticesBox.$listContainer.css({'height': listHeight + "px"});
}


function tmplToHtml(s) {
  return s.replace(/\n/g, "<br />");
}

function tmplTrunc(s, count) {
  return Ox.truncate(s, count, "...", "right"); 
}

/*
  //FIXME: make sure to add a loading icon
  Ox.Request.requests() && app.$ui.loadingIcon.start();
  Ox.Event.bind('', 'requestStart', function() {
      Ox.print('requestStart')
      app.$ui.loadingIcon.start();
  });
  Ox.Event.bind('', 'requestStop', function() {
      Ox.print('requestStop')
      app.$ui.loadingIcon.stop();
  });
*/

//  $(body).append(app.$ui.wrapper);
    




/*
Ox.Box - generic box element, with a bar, some help, search, a menu, etc.
*/







