## The contents of this file are subject to the Common Public Attribution
## License Version 1.0. (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License at
## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
## License Version 1.1, but Sections 14 and 15 have been added to cover use of
## software over a computer network and provide for limited attribution for the
## Original Developer. In addition, Exhibit A has been modified to be consistent
## with Exhibit B.
##
## Software distributed under the License is distributed on an "AS IS" basis,
## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
## the specific language governing rights and limitations under the License.
##
## The Original Code is Reddit.
##
## The Original Developer is the Initial Developer.  The Initial Developer of
## the Original Code is CondeNet, Inc.
##
## All portions of the code written by CondeNet are Copyright (c) 2006-2010
## CondeNet, Inc. All Rights Reserved.
################################################################################

<%!
   from r2.lib.template_helpers import static, s3_https_if_secure
   from r2.models import Sub, FakeSubreddit
   from r2.models.subreddit import DefaultSR
   from r2.lib.pages import SearchForm
%>
<%namespace file="utils.html" import="plain_link, text_with_js, img_link, separator, logout"/>

<div id="header">
  <a tabindex="1" href="#content" id="jumpToContent">${_('jump to content')}</a>
  ${thing.srtopbar}
  <div id="header-bottom-${'right' if c.lang_rtl else 'left'}">
    <%
        header_title = c.site.header_title
        if c.site.header and c.allow_styles:
            header_img = c.site.header
        else:
            d = DefaultSR()
            header_img = d.header
            header_title = d.header_title
    %>
    ${img_link(c.site.name, s3_https_if_secure(header_img), '/', _id = "header-img-a", img_id = 'header-img', title = header_title)}

    ##keeps the height of the header from varying when there isnt any content
    &nbsp;

    %for toolbar in thing.toolbars:
      ${toolbar}
    %endfor
  </div>

  <div id="header-bottom-${'left' if c.lang_rtl else 'right'}">
    %if not c.user_is_loggedin:
      %if thing.enable_login_cover:
      <span class="user">
        ${text_with_js(_("want to join? %(register)s in seconds"),
                          register=(_("register"), "return showcover(false);"))}
      </span>
      ${separator("|")}
      %endif
    %else:
      <span class="user">
         ${plain_link(c.user.name, "/user/%s/" % c.user.name, _sr_path=False)}
         &nbsp;(<b>${c.user.safe_karma}</b>)
      </span>

      ${separator("|")}

      <%
         mail_img ="mail"
         if c.have_messages:
           mail_img += ".png"
           mail_img_class = 'havemail'
           mail_img_title = "new mail!"
           mail_path = "/message/unread/"
         else:
           mail_img += "gray.png"
           mail_img_class = 'nohavemail'
           mail_img_title = "no new mail"
           mail_path = "/message/inbox/"
         mail_img = static(mail_img)
       %>
      ${img_link(_("messages"), mail_img, path=mail_path,
                 alt = mail_img_title, title = mail_img_title, 
                 _id = "mail", _class=mail_img_class)}
      ${separator("|")}
      %if c.show_mod_mail:
         <%
            mail_img ="modmail"
            if c.have_mod_messages:
              mail_img += ".png"
              mail_img_class = 'havemail'
              mail_img_title = "new mail!"
              mail_path = "/message/moderator/"
            else:
              mail_img += "gray.png"
              mail_img_class = 'nohavemail'
              mail_img_title = "no new mail"
              mail_path = "/message/moderator/"
            mail_img = static(mail_img)
          %>
         ${img_link(_("mod messages"), mail_img , path=mail_path,
                    alt = mail_img_title, title = mail_img_title, 
                    _id = "modmail", _class=mail_img_class)}
         ${separator("|")}
      %endif
    %endif
    ${thing.corner_buttons()}
    %if c.user_is_loggedin:
      ${separator("|")}
      ${logout()}
    %endif
  </div>
</div>

<div class="preload">
## everything in here will get rendered off screen for pre-fetching purposes.
  <div class="arrow up"></div>
  <div class="arrow upmod"></div>
  <div class="arrow down"></div>
  <div class="arrow downmod"></div>
  <div class="eb-sch"></div>
  <div class="eb-se"></div>
  <div class="eb-seh"></div>
  <div class="eb-vch"></div>
  <div class="eb-ve"></div>
  <div class="eb-veh"></div>
  <div class="morelink nub"></div>
  <div class="mlh"></div>
  <div class="mlhn"></div>
  <div class="sidebox gold"><div class="morelink"></div></div>
  <a class="pretty-button negative"></a>
  <a class="pretty-button negative pressed"></a>
  <a class="pretty-button positive"></a>
  <a class="pretty-button positive pressed"></a>
## Be careful when adding things here: If all users try to get the new images
## at once, they'll crush the static servers!
</div>
