<inp2:adm_SetPopupSize width="700" height="600"/>
<inp2:m_include t="incs/header"/>

<inp2:m_NoDebug/>
<inp2:m_RenderElement name="combined_header" prefix="c" section="in-portal:browse" title_preset="edit_content"/>

<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
	<tr>
	  	<td>
	  		<script type="text/javascript">
				a_toolbar = new ToolBar();

	  			a_toolbar.AddButton(
	  				new ToolBarButton(
	  					'select',
	  					'<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>',
	  					function() {
							submit_event('content', 'OnSaveContentBlock');
						}
					)
				);

				a_toolbar.AddButton(
					new ToolBarButton(
						'cancel',
						'<inp2:m_phrase label="la_ToolTip_Close" escape="1"/>',
						function() {
							window_close();
						}
					)
				);

				a_toolbar.Render();
			</script>

		</td>

		<inp2:m_RenderElement name="ml_selector" prefix="content"/>
	</tr>
</tbody>
</table>

<inp2:content_SaveWarning name="grid_save_warning"/>
<inp2:content_ErrorWarning name="form_error_warning"/>

<inp2:content_FCKEditor field="Content" width="99%" height="100" format="no_default"/>

<input type="hidden" name="c_id" value="<inp2:m_Get name='c_id'/>"/>

<script type="text/javascript">
	var $field_id = '<inp2:content_InputName name="Content" js_escape="1"/>',
		$autosave_title = '<inp2:m_Phrase name="la_title_EditingContentAutosaved" no_editing="1" js_escape="1"/>';

	CKEDITOR.on(
		'instanceReady',
		function( ev ) {
			var $editor_instance = CKEDITOR.instances[ ev.editor.name ];
			$editor_instance.resize( '100%', $(window).height() - $('#cke_' + jq($field_id)).offset().top );
		}
	);

	$(document).ready(
		function () {
			$(window).resize(
				function ($e) {
					for (var $index in CKEDITOR.instances) {
						CKEDITOR.instances[$index].resize( '100%', $(window).height() - $('#cke_' + jq($field_id)).offset().top );
					}
				}
			);
		}
	);

	<inp2:m_if check="m_GetConfig" name="EnablePageContentRevisionControl">
		setInterval(
			function () {
				var $editor_instance = CKEDITOR.instances[ '<inp2:content_InputName field="Content"/>' ];
				$('#' + jq('<inp2:content_InputName field="Content"/>')).val( $editor_instance.getData() );

				submit_event_ajax(
					'content', 'OnAutoSave', undefined,
					function ($autosave_string) {
						$('#blue_bar').html( $autosave_title.replace('%s', $autosave_string) );
					}
				);
			}, <inp2:m_GetConst name="CONTENT_LASTAUTOSAVE_UPDATE_INTERVAL"/> * 1000
		);

		setInterval(
			function () {
				submit_event_ajax(
					'content', 'OnGetAutoSaveTime', undefined,
					function ($autosave_string) {
						if ( $autosave_string ) {
							$('#blue_bar').html( $autosave_title.replace('%s', $autosave_string) );
						}
					}
				);
			}, <inp2:m_GetConst name="CONTENT_LASTAUTOSAVE_REFRESH_INTERVAL"/> * 1000
		);
	</inp2:m_if>
</script>

<inp2:m_include t="incs/footer"/>