{#
    cloud/layout.html
    ~~~~~~~~~~~~~~~~~

    Sphinx layout template for the cloud theme.

    :copyright: Copyright 2009-2011 Assurance Technologies LLC
    :license: BSD

    roottarget - optional target for root link (default to toc)
    logotarget - optional target for logo link (defaults to root target)
    googleanalytics_id - if set, enabled google analytics snippet & footer
    googleanalytics_path - optional subpatch for GA cookie
    collapsiblesidebar - enable collapsible sidebar support

#}

{% extends "basic/layout.html" %}

{% set reldelim2 = reldim2 is not defined and ' &nbsp; &nbsp;' or reldelim2 %}

{# add script file to instrument collapsable sections  and other features #}
{% set script_files = script_files + ['_static/jquery.cookie.js',
                                      '_static/toggle_sections.js'] %}
{% if theme_collapsiblesidebar|tobool %}
{% set script_files = script_files + ['_static/toggle_sidebar.js'] %}
{% endif %}

{# add font stylesheets #}
{% set css_files = css_files + [theme_fontcssurl] %}

{# make root link redirectable #}
{%- set theme_roottarget = (theme_roottarget == "<toc>" and master_doc or theme_roottarget) %}
{% block rootrellink %}
    <li><a href="{{ pathto(theme_roottarget) }}">{{shorttitle|e}}</a>{{reldelim1}}</li>
{% endblock %}

{# make logo link redirectable #}
{%- set theme_logotarget = (theme_logotarget == "<root>" and theme_roottarget or (theme_logotarget == "<toc>" and master_doc or theme_logotarget)) %}
{%- block sidebarlogo %}
    {%- if logo %}
        <p class="logo"><a href="{{ pathto(theme_logotarget) }}">
          <img class="logo" src="{{ pathto('_static/' + logo, 1) }}" alt="Logo"/>
        </a></p>
    {%- endif %}
{%- endblock %}

{# wrap relbars in distinct classes to make themeing easier #}
{%- block relbar1 %}
    <div class="relbar-top">
        {{ super() }}
    </div>
{% endblock %}

{%- block relbar2 %}
    <div class="relbar-bottom">
        {{ super() }}
    </div>
{% endblock %}

{% block extrahead -%}
        {{ super() }}
        {%- if theme_googleanalytics_id -%}
<script type="text/javascript">
var ga_enabled = !$.cookie('disable-ga');
if(ga_enabled){
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '{{ theme_googleanalytics_id }}']);
  _gaq.push(['_setCookiePath', '{{ theme_googleanalytics_path }}']);
  _gaq.push(['_setDetectFlash', false]);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
}
</script>
        {%- endif %}
{%- endblock %}

{% block footer -%}
    {{ super() }}

    {%- if theme_googleanalytics_id -%}
<script type="text/javascript">
    if(ga_enabled){
        document.write("<div class=\"footer\">This page uses <a href=\"http://analytics.google.com\">Google Analytics</a> to collect statistics. ");
        document.write("Click <button title=\"set cookie to disable analytics for this site\" class=\"link\" onclick=\"$.cookie('disable-ga', 'true', {expires: 3650, path: '{{ theme_googleanalytics_path }}'}); window.location.reload(); return false; \">here</button> to disable analytics for this site.");
        document.write("</div>");
    }else{
        document.write("<div class=\"footer\">Google Analytics has been disabled. ");
        document.write("Click <button title=\"set cookie to re-enable analytics for this site\" class=\"link\" onclick=\"$.cookie('disable-ga', null, {path: '{{ theme_googleanalytics_path }}'}); window.location.reload(); return false; \">here</button> to re-enable analytics for this site.");
    };
</script>
    {%- endif %}
    <!-- cloud_sptheme 1.3 -->
{%- endblock %}
