!!!	
%html

  %head
    %title=current_namespace.title

    %script(type="text/javascript" src="#{path_prefix}/vendor/jquery-1.6.1.min.js")
    %script(type="text/javascript" src="#{path_prefix}/vendor/highcharts.js")

    %script(type="text/javascript" src="#{path_prefix}/fnordmetric.js")
    %link(type="text/css" rel="stylesheet" href="#{path_prefix}/fnordmetric.css")

    :javascript
      FnordMetric.p = '#{path_prefix}';

  %body
    .topbar{:class => namespaces.count > 1 ? 'shown' : 'hidden'}
      %ul
        -namespaces.each do |key,namespace|
          %li{:class => namespace.token == current_namespace.token ? 'active' : nil}
            %a{:href=>"/#{namespace.token}"}=h namespace.title

    #wrap
      #tabs
        %ul
          - if current_namespace.active_users_available
            %li.active.sessions
              .picto.piechart
              Active Users

          -current_namespace.dashboards.each do |key,dashboard|
            %li.dashboard{:rel => dashboard.token}
              .picto.piechart
              =h dashboard.title

      #viewport
        .viewport_inner.clearfix
            

:javascript
  $(document).ready(function(){

    FnordMetric.init('#{current_namespace.token}', $('.viewport_inner'));

    $('#tabs li.dashboard').click(function(){
      FnordMetric.renderDashboard($(this).attr('rel'));
      window.location.hash = $(this).attr('rel');
    });

    $('#tabs li.sessions').click(function(){
      FnordMetric.renderSessionView();
      window.location.hash = '';
    });

    $('#tabs li').click(function(){
      $(this).addClass('active').siblings().removeClass('active');
    });

    function resizeViewport(){ 
      var viewport_width = window.innerWidth-220
      $('#viewport').width(viewport_width); 
      FnordMetric.resizeView();
    }

    resizeViewport();
    $(window).resize(resizeViewport);

    if(!#{current_namespace.active_users_available.to_s}) {
      $('#tabs li:first').trigger('click');
    }
    
    if(window.location.hash){
      $('#tabs li.dashboard[rel="'+window.location.hash.slice(1)+'"]').trigger('click');
    }

  });