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

<inp2:m_NoDebug/>
<inp2:m_Set skip_last_template="1"/>
<inp2:m_RenderElement name="combined_header" prefix="trans" section="in-portal:root" title_preset="trans_edit"/>

<!-- 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();
			  		var $TargetField = '<inp2:m_Get name="TargetField" js_escape="1"/>';

	  				a_toolbar.AddButton(
	  					new ToolBarButton(
	  						'select',
	  						'<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>',
	  						function() {
								var $opener = getWindowOpener(window);

								if (!$opener) {
									return;
								}

								if (!$opener.closed) {
									$opener.document.getElementById($TargetField).value = CKEDITOR.instances['Content'].getData();
								}

								window_close();
							}
						)
					);

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

					a_toolbar.Render();
				</script>

			</td>
		</tr>
	</tbody>
</table>

<inp2:adm_FCKEditor name="Content" width="99%" height="100" bgcolor="red"/>

<script type="text/javascript">
	CKEDITOR.on(
		'instanceReady',
		function( ev ) {
			var $opener = getWindowOpener(window);
			var $editor_instance = CKEDITOR.instances[ ev.editor.name ];

			if ($opener && !$opener.closed) {
				$editor_instance.setData( $opener.document.getElementById($TargetField).value );
				$editor_instance.resize( '100%', $(window).height() - $('#cke_Content').offset().top );
			}
			else {
				window_close();
			}
		}
	);

	$(document).ready(
		function () {
			$(window).resize(
				function ($e) {
					for (var $index in CKEDITOR.instances) {
						CKEDITOR.instances[$index].resize( '100%', $(window).height() - $('#cke_Content').offset().top );
					}
				}
			);
		}
	);
</script>

<inp2:m_Set _force_popup="1"/>
<inp2:m_include t="incs/footer"/>