Template.tabs.helpers({
  class_for: function(tab_name) {
    var templateName = Session.get('templateName');

    if (templateName === tab_name) {
      return tab_name + ' active';
    } else if (templateName === 'display' && tab_name === 'news') {
      return tab_name + ' active'
    } else {
      return tab_name;
    }
  },

  selected_controller: function() {
    return Session.get('controller_id');
  },

  accessible: Meteor.zoblak.client.accessible
});



Template.tabs.events({
  'click .start': function() {
    Router.go('/');
  },
  'click .weather': function() {
    Router.go('/weather');
  },
  'click .log': function() {
    Router.go('/log');
  },
  'click .surveillance': function() {
    Router.go('/surveillance');
  },

  'click .alarm': function() {
    Router.go('/alarm');
  },
  'click .settings': function() {
    Session.set('templateName', 'settings');
  },

  'click #switch': function() {
    var instance = Template.instance();
    controller_id = instance.$('#controller').val();
    Session.setPersistent('controller_id', controller_id);
  }
});
