{% extends "ldt/ldt_raw_base.html" %}
{% load i18n %}
{% load logintag %}
{% load navigation %}
{% load absstatic %}
{% load thumbnail %}

{% block js_import %}
	<script type="text/javascript">
		var project_load_src = '{% absstatic "ldt/img/ajax-loader-transp.gif" %}'; // Required for search bar icon in projectscontents.js
	</script>
	
    {{ block.super }}
    <script type="text/javascript" src='{% absstatic "ldt/js/jquery.nyroModal.min.js" %}'></script>
    <!--[if IE 6]>
    <script type="text/javascript" src='{% absstatic "ldt/js/jquery.nyroModal-ie6.min.js" %}'></script>
    <![endif]-->
    <script type="text/javascript" src='{% absstatic "ldt/js/jquery.qtip.min.js" %}'></script>
    <script type="text/javascript" src='{% absstatic "ldt/js/jquery.validate.js" %}' ></script>
{% endblock %}

{% block js_declaration %}
    <script type="text/javascript">    

    jQuery(function($, undefined) {
    $.nmFilters({iriIframe:{
        is: function(nm) {
            var target = nm.opener.attr('target') || '',
                rel = nm.opener.attr('rel') || '',
                opener = nm.opener.get(0);
            return !nm._hasFilter('image') && (target.toLowerCase() == '_iri'
                || rel.toLowerCase().indexOf('external') > -1
                || (opener.hostname && opener.hostname.replace(/:\d*$/,'') != window.location.hostname.replace(/:\d*$/,'')));
        },
        init: function(nm) {
            nm.loadFilter = 'iframe';
        },
        load: function(nm) {
            nm.store.iframe = $('<iframe src="javascript:\'\';"></iframe>');
            nm._setCont(nm.store.iframe);
        },
        afterShowCont: function(nm) {
            nm.store.iframe.attr('src', nm.opener.attr('href'));
        },
        close: function(nm) {
            // Since we hacked the iriIframe jquery close filter from the file projectscontents.js,
            // this close function seems not useful anymore.
            if (nm.store.iframe) {
                var res =  $('#ldtInitSwf',nm.store.iframe.contents());
                if(res.length > 0) {
                    if(res.get(0).isModified()=="true") {
                        res.get(0).askSave();
                    }
                    else{
                        nm.store.iframe.remove();
                        nm.store.iframe = undefined;
                        delete(nm.store.iframe);
                    }
                }
                else{
                    nm.store.iframe.remove();
                    nm.store.iframe = undefined;
                    delete(nm.store.iframe);
                }
            }
        }
    }});
    });
    
    </script>
{% endblock %}
        
{% block css_import %}
    {{ block.super }}
    <link rel="stylesheet" href='{% absstatic "ldt/css/tabs.css" %}' type="text/css" media="screen, projection" />
    <link rel="stylesheet" href='{% absstatic "ldt/css/nyroModal.css" %}' type="text/css"/>
    <link rel="stylesheet" href='{% absstatic "ldt/js/login_ajax/login_ajax.css" %}' type="text/css"/>
    <link rel="stylesheet" href='{% absstatic "ldt/css/jquery.qtip.min.css" %}' type="text/css"/>
{% endblock %}
    
{% block body %}
    {{ block.super }}
    <div class="container">
    <div id="header">      
        {% block header %}
        <div id="header_left">
            <p><a href="{% url ldt.ldt_utils.views.workspace.home %}">{% block base_title %}{% trans "header_title" %}{% endblock %}</a></p>
        </div>
        <div id="loginstate" >
	        {% if user.is_staff %}
	        	<a href="{% url admin:index %}" title="{% trans "Link to admin" %}">{% trans "Staff" %}</a>|
	        {% endif %}
            {% if user.is_authenticated %}
            <a href="{% url front_home %}" title="{% trans "front link" %}">{% trans "front link" %}</a> |            
            <a href="{% url ldt.user.views.profile %}"  title="{% trans "Profile change" %}">
              {% thumbnail user.get_profile.image "20x20" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %}&nbsp;{% endthumbnail %}
              {{user.username}}</a>
            |&nbsp;<a href="{% url ldt.user.views.logout_view %}" title="{% trans "Log out" %}">{% trans "Log out" %}</a>
            {% endif %}
        </div>
        {% endblock %}
    </div>
    <div id="content" class="span-24 last">
        <div id="toolbar" class="span-24 last">
        {% block toolbar %}
            <div class="block span-24 last">
                <div id="tabsdiv" class="block span-20">
                {% if user.is_authenticated %}
                {% url ldt.ldt_utils.views.workspace.home as workspace_url %}
                {% url ldt.ldt_utils.views.workspace.groups as groups_url %}
                {% url ldt.ldt_utils.views.workspace.published_project as published_project_url %}
                {% url ldt.user.views.profile  as profile_url %}
                {% url ldt.ldt_utils.views.workspace.search_form  as search_url %}
                    <ul class="tabs">
                        <li class='{% active request "active" workspace_url %}'><a href="{{ workspace_url }}" title="{% trans "home" %}">{% trans "home" %}</a></li>
                        <li class='{% active request "active" groups_url %}'><a href="{{ groups_url }}" title="{% trans "home" %}">{% trans "My groups" %}</a></li>
                        <li class='{% active request "active" published_project_url %}'><a href="{{ published_project_url }}" title="{% trans "Published projects" %}" >{% trans "Published projects" %}</a></li>
                        {% comment %}
                        <li class='{% active request "active" "" %}'><a href="#">{% trans "accounts" %}</a></li>
                        <li class='{% active request "active" profile_url %}'><a href="{{ profile_url }}" >{% trans "Profiles" %}</a> </li>
                        {% endcomment %}
                    </ul>
                {% endif %}
                </div>
                {% if user.is_authenticated %}
		        <div class="block span-4 last">
		            <form method="get" id="quick_search_form" action="{% url ldt.ldt_utils.views.workspace.search_index %}" title="{% trans "search"%}" accept-charset="utf-8">
					<input type="text" name="search" id="id_search" size="16"/>
					<input type='hidden' name='field' value='all' />
					<input type="submit" class="quick_search_submit" value="" />					
					</form>
		        </div>
		        {% endif %}
            </div>
        {% endblock %}
        </div>
        <div id="inner_content" class="span-24 last">
        {% block content %}{% endblock %}
        </div>      
    </div>
    <div id="footer" class="span-24 last">
        {% block footer %}
        <div class="footer_img">
        <a href="http://www.iri.centrepompidou.fr"><img src='{% absstatic "ldt/img/logo_IRI_footer.png" %}' alt="Logo IRI" /></a>
        </div>
        <div style="float: right; text-align: right;" class="small" id="copyright_version">
        	<div>©2011 <a style="text-decoration: none; color: #4F5155;" href="http://www.iri.centrepompidou.fr">IRI</a></div>
        	<div id="versionwrapper"><span class="version" id="version" title="{% trans "Version number" %}"> {% blocktrans %} web {{WEB_VERSION}} | platform {{ VERSION }}{% endblocktrans %}</span></div>
        </div>
        {% endblock %}
    </div>
    </div>
{% endblock %}
