<!DOCTYPE html>

<%= render :partial => 'layouts/version.html.erb' %>

<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
		<title><%= content_for?(:title) ? yield(:title) : "Snorby #{Snorby::VERSION}" %></title>
		
		<meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta name="description" content="Snorby - All About Simplicity" />
    <link rel="icon" href="/favicon.png" type="image/png" />

		<% @severities ||= Severity.all %>

		<script type="text/javascript">
			<% @severities.each do |sev| %>
				var sev<%= sev.sig_id %>_bg_color = '<%= sev.bg_color %>';
      <% end %>

      var current_user = <%= @current_user.to_json(
        :only => [
          :email,
          :name,
          :sign_in_count,
          :current_sign_in_ip,
          :last_sign_in_ip,
          :id,
          :admin
        ]
      ).html_safe %>;
		</script>

		<%= csrf_meta_tag %>

		<%= include_stylesheets :snorby, :media => 'all' %>
		<%= include_javascripts :snorby %>

		<%= yield(:header) %>

		<style type="text/css">
			<%- @severities.each do |sev| -%>
        ul.table li div.small span.severity.sev<%= sev.sig_id %>,
        span.severity.sev<%= sev.sig_id %>{
					background-color: <%= sev.bg_color %>;
					color: <%= sev.text_color %>;
				}
			<%- end -%>
		</style>

  </head>
  
	<body>
		
		<%= render :partial => 'layouts/header.html.erb' %>

    <div id="wrapper">
      <%= render :partial => 'layouts/content.html.erb' %>		
    </div>

		<%= render :partial => 'layouts/footer.html.erb' %>
		
		<%- flash.each do |type, message| -%>

      <script type="text/javascript" charset="utf-8">
        flash_message.push({type: "<%= type %>", message: "<%= message %>"}); flash();
      </script>

    <%- end -%>
		
    <%= yield(:footer) %>

    <%= render :partial => 'layouts/notify' %>

    <script type="text/javascript" charset="utf-8">
      <% if Setting.update_notifications? %>
        if (!$.cookie('snorby-ignore-update')) {
          $.ajax({
            url: 'https://www.snorby.org/version?current_version=<%= Snorby::VERSION%>',
            dataType: "jsonp",
            global: false,
            crossDomain: true,
            success: function(data) {
              if (data && (typeof data === "object")) {
                if (data.version !== "<%= Snorby::VERSION %>") {
                  $('#header-top').append(Snorby.templates.update_notifications(data));
                };
              };
            }
          });
        };
      <% end %>

      <% if Setting.event_notifications? %>
        monitor_events(false);
      <% else %>
        if (window.location.pathname === "/events") {
          monitor_events(true);
        };
      <% end %>
    </script>

  </body> 
</html> 
