<%#
  # @file
  # Main application file. Holds scaffolding present on every page.
  # Then a certain non-partial view (no _ preceding filename) will be
  # displayed within, based on URL
  #%>

<!DOCTYPE html>
<html>
<head>
  <title><%=h yield(:title) %></title>
  <% if authenticated? %>
    <script type="text/javascript">
      var userid = <%= user.id %>;
      var username = "<%= user.name %>";
    </script>
  <% else %>
    <script type="text/javascript">
      var userid = null;
      var username = null;
    </script>  
  <% end %>
  <script>
    var imgArray = new Object();
    
    <% Metacode.all.each do |m| %>
      imgArray['<%= m.name %>'] = new Image(); imgArray['<%= m.name %>'].src = '/assets/<%= m.icon %>';
    <% end %>
  </script>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <script type="text/javascript" src="//use.typekit.net/tki2nyo.js"></script>
  <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
  <script type="text/javascript" src="//use.typekit.net/obp7wss.js"></script>
  <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
  <%= csrf_meta_tags %>
</head>
<body class="<%= (action_name == "show") ? "mapBody" : "" %>" >

  <% if notice %>
  <p class="notice metamaps"><%= notice %></p>
  <% end %>
  <% if alert %>
  <p class="alert metamaps"><%= alert %></p>
  <% end %>
       
  <%= content_tag :div, class: authenticated? ? "main authenticated" : "main unauthenticated" do %>

    <div class="wrapper" id="wrapper">
      <div class="sidebarSearch">
        <div class="sidebarSearchIcon"></div>
        <input type="text" class="sidebarSearchField"></input>
        <div class="clearfloat"></div>
        <%= render :partial => 'layouts/searchtemplates' %>
      </div>
      <div class="sidebarAccount">
        <div class="sidebarAccountIcon"></div>
        <div class="sidebarAccountBox <%= authenticated? ? 'loggedin' : 'loggedout' %>">
          <%= render :partial => 'layouts/account' %>
        </div>
      </div>
			<%= yield %>
		</div>
		
		<div class="footer">
      <div class="logo">
          <ul class="menu">
                <li class="beta" onclick="BAROMETER.show();">
                    FEEDBACK!
                </li>
                <li class="meta openLightbox" data-open="about">ABOUT</li>
                <li class="tutorial openLightbox" data-open="tutorial">TUTORIAL</li>
                <li class="exploreMaps"><%= link_to "EXPLORE MAPS", featuredmaps_url %></li>
          </ul>
          <div id="mainTitle"><%= link_to "metamaps", root_url %></div><!--<div id="beta">beta</div>-->
      </div>
      <% if authenticated? %>
        <div class="addMap openLightbox" data-open="newmap"></div>
      <% end %>
    </div>
    
  <% end %>
  
    <style type='text/css'>@import url('http://getbarometer.s3.amazonaws.com/assets/barometer/css/barometer.css');</style>
    <script src='http://getbarometer.s3.amazonaws.com/assets/barometer/javascripts/barometer.js' type='text/javascript'></script>
    <script type="text/javascript" charset="utf-8">
      BAROMETER.load('Scqak8nyHdFEkezKMNeQp');
    </script>
  <%= render :partial => 'layouts/lightboxes' %>
  <%= render :partial => 'layouts/ga' if Rails.env.production? %>
</body>
</html>
