form(class="form-horizontal subroot", style="overflow: hidden; height: 100%;" role="form", id="form")
	.new_flex_zero(style="padding-left: 15px; padding-right: 15px; ")
		p(style="font-style: italic;") #{parish_name} <span class="glyphicon glyphicon-chevron-right", aria-hidden="true"></span> #{factory_name} <span style="font-size: 80%">(!{timespan})</span>
		
		button(class="btn btn-warning btn-xs", type="button", onclick="history.back();") 
			span(class="glyphicon glyphicon-remove-circle", aria-hidden="true")
			span 
			span Zurück
			
		button(class="btn btn-success btn-xs", type="button", onclick="go_forward_to(pcalpub_steps.ADDRESSCHOOSER,pcalpub_choose_addresses);") 
			span(class="glyphicon glyphicon-ok", aria-hidden="true")
			span 
			span Weiter
	
		.row
			.col-sm-12
				span &nbsp;
	
	.new_flex_one(style="overflow: auto; padding-left: 15px; padding-right: 15px; padding-bottom: 15px; height: 100%;")
		textarea#html_for_email
			!{html}
		
	script.
		function resize() {
			console.log('resize called');
			setTimeout(function () {
			// Main container
			var max = $('.mce-tinymce')
				.parent().outerHeight();
				
				//.css('border', 'none')

			// Menubar
			max += -$('.mce-menubar.mce-toolbar').outerHeight(); 

			// Toolbar
			max -= $('.mce-toolbar-grp').outerHeight(); 
			
			// Statusbar
			max -= $('.mce-statusbar').outerHeight(); 
			
			// Random fix lawl - why 1px? no one knows
			max -= 3;
			
			// And the padding
			max -= 15;

			// Set the new height
			$('.mce-edit-area').height(max);
			}, 200);
		}

		tinymce.editors=[];
		tinymce.init({
			selector: '#html_for_email',
			height: '100%',
			resize: false,
			autoresize: true,
			init_instance_callback : function(editor) { resize(); },
			language: 'de',
			plugins: 'advlist,autolink,lists,link,image,charmap,print,preview,anchor,searchreplace,visualblocks,code,insertdatetime,media,table,contextmenu,paste',
			toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image'
			});
	
		$(window).on('resize', function () {
			resize();
		});

//	.new_flex_one(style="overflow: auto; padding-left: 15px; padding-right: 15px;")
//
//		.row
//			fieldset(class="col-sm-12", style="margin-top: 20px;")
//				legend(style="font-size: 150%") Terminmeldung
//				textarea(class="form-control", rows="5", id="area_description", name="area_description").
//					#{event.description}
