{% load i18n %}
<script type="text/javascript">

$(document).ready(function(){
{% if editable %}
	$("a.colorbox-form").colorboxify({
		close_popup_and_media_slide: function() {
			$.colorbox.close();
			$("#coopbar_medialibrary").click();
		}
	})
{% endif %}
{% if edit_mode %}
	$("#coop-bar a.slide").pageSlide({width:'350px', direction:'right'});
	
	var toggle_save = function() {
	    if (!$(".show-dirty").is(":visible")) {
			$(".show-clean").hide();
			$(".show-dirty").show();
			$("a.alert_on_click").bind('click', function(event) {
				return confirm("{% trans 'Your modifications are not saved and will be lost. Continue?' %}");
			});
		}
		{% if draft %}
		$(".publish").hide();
		{% endif %}
	}
	$(".show-dirty").hide();
	GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha, "editableDeactivated",
        //Callback called when the fragment edition is done -> Push to the page
        function(event, eventProperties) {
            toggle_save();
        }
    );
	$(".djaloha-editable").keypress(function() {
		toggle_save();
	});
	
	$("a.update-logo img").change(toggle_save);
	$(".article select").change(toggle_save);
	$(".article input").change(toggle_save);
{% endif %}
});
</script>
