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

<inp2:m_RenderElement name="combined_header" section="in-portal:promo_block_groups" prefix="promo-block" title_preset="promo_block_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();
				a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
							submit_event('promo-block', '<inp2:promo-block_SaveEvent/>');
						}
					) );
				a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
							cancel_edit('promo-block', 'OnCancelEdit','<inp2:promo-block_SaveEvent/>','<inp2:m_Phrase label="la_FormCancelConfirmation" escape="1"/>');
						}
				 ) );

			 	a_toolbar.AddButton( new ToolBarButton('reset_edit', '<inp2:m_phrase label="la_ToolTip_Reset" escape="1"/>', function() {
						reset_form('promo-block', 'OnReset', '<inp2:m_Phrase label="la_FormResetConfirmation" escape="1"/>');
					}
			 	) );

				a_toolbar.AddButton( new ToolBarSeparator('sep1') );

				a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
							go_to_id('promo-block', '<inp2:promo-block_PrevId/>');
						}
				 ) );
				a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
							go_to_id('promo-block', '<inp2:promo-block_NextId/>');
						}
				 ) );

				a_toolbar.Render();

				<inp2:m_if check="promo-block_IsSingle" >
					a_toolbar.HideButton('prev');
					a_toolbar.HideButton('next');
					a_toolbar.HideButton('sep1');
				<inp2:m_else/>
					<inp2:m_if check="promo-block_IsLast" >
						a_toolbar.DisableButton('next');
					</inp2:m_if>
					<inp2:m_if check="promo-block_IsFirst" >
						a_toolbar.DisableButton('prev');
					</inp2:m_if>
				</inp2:m_if>
			</script>

			<script type="text/javascript" src="js/swfobject.js"></script>
			<script type="text/javascript" src="<inp2:m_Compress files='js/uploader/upload_manager.js|js/uploader/uploader.js'/>"></script>

			<inp2:m_RenderElement name="ml_selector" prefix="promo-block"/>
		</td>
	</tr>
</tbody>
</table>

<inp2:m_DefineElement name="multilang_field_caption_element">
	<label for="<inp2:m_param name='NamePrefix'/><inp2:{$prefix}_InputName field='$field'/>">
		<span class="<inp2:m_if check='{$prefix}_HasError' field='$field'>error-cell</inp2:m_if>"><inp2:m_if check="m_Param" name="title"><inp2:lang_Field field="LocalName"/> <inp2:m_phrase label="$title"/></inp2:m_else/><inp2:lang_Field field="LocalName"/> <inp2:m_Param name="title_text"/></inp2:m_if></span></span><inp2:m_if check="{$prefix}_IsRequired" field="$field"><span class="field-required">&nbsp;*</span></inp2:m_if>:<inp2:m_if check="m_Param" name="hint_label"><span>&nbsp;<img src="<inp2:m_TemplatesBase/>/img/hint_icon.png" width="12" height="13" title="<inp2:m_Phrase label='$hint_label' html_escape='1'/>" alt="<inp2:m_Phrase label='$hint_label' html_escape='1'/>"/></inp2:m_if>
	</label>
</inp2:m_DefineElement>

<inp2:m_DefineElement name="date_field_caption_element">
	<label for="<inp2:m_param name='NamePrefix'/><inp2:{$prefix}_InputName field='$field'/>">
		<span class="<inp2:m_if check='{$prefix}_HasError' field='$field'>error-cell</inp2:m_if>"><inp2:m_if check="m_Param" name="title"><inp2:m_phrase label="$title"/></inp2:m_else/><inp2:m_Param name="title_text"/></inp2:m_if> <span class="small">(<inp2:promo-block_Format field="ScheduleFromDate_date" input_format="1" human="true"/>)</span></span></span><inp2:m_if check="{$prefix}_IsRequired" field="$field"><span class="field-required">&nbsp;*</span></inp2:m_if>:<inp2:m_if check="m_Param" name="hint_label"><span>&nbsp;<img src="<inp2:m_TemplatesBase/>/img/hint_icon.png" width="12" height="13" title="<inp2:m_Phrase label='$hint_label' html_escape='1'/>" alt="<inp2:m_Phrase label='$hint_label' html_escape='1'/>"/></inp2:m_if>
	</label>
</inp2:m_DefineElement>

<inp2:promo-block_SaveWarning name="grid_save_warning"/>
<inp2:promo-block_ErrorWarning name="form_error_warning"/>

<div id="scroll_container">
	<table class="edit-form">
		<inp2:m_RenderElement name="inp_id_label" prefix="promo-block" field="BlockId" title="la_fld_Id"/>
		<inp2:m_RenderElement name="inp_edit_options" prefix="promo-block" field="PromoBlockGroupId" title="la_fld_PromoBlockGroup" has_empty="1"/>
		<inp2:m_RenderElement name="inp_edit_box_ml" prefix="promo-block" field="Title" maxlength="50"/>
		<inp2:m_RenderElement name="inp_edit_textarea_ml" prefix="promo-block" field="Html" title="la_fld_Text" control_options="{min_height: 60}" rows="4" cols="70"/>
		<inp2:m_RenderElement name="inp_edit_box_ml" prefix="promo-block" field="ButtonText"/>

		<inp2:m_RenderElement name="inp_edit_options" prefix="promo-block" field="Priority" title="la_fld_Order"/>
		<inp2:m_RenderElement name="inp_edit_radio" prefix="promo-block" field="Status"/>

		<inp2:m_DefineElement name="image_block">
			<inp2:Field field="LanguageId" result_to_var="langId"/>
			<inp2:m_RenderElement name="inp_edit_swf_upload" caption_render_as="multilang_field_caption_element" prefix="promo-block" field="l{$langId}_Image" title="la_fld_Image"/>
		</inp2:m_DefineElement>

		<inp2:lang_ListLanguages render_as="image_block" row_start_render_as="html:" row_end_render_as="html:"/>

		<!--##<inp2:m_RenderElement name="inp_edit_options" prefix="promo-block" field="CSSClassName" has_empty="1"/>##-->
		<inp2:m_RenderElement name="inp_edit_options" prefix="promo-block" field="LinkType" onchange="select_link_type()"/>
		<inp2:m_RenderElement name="inp_edit_options" prefix="promo-block" field="CategoryId" title="la_fld_Category" style="width: 400px;" has_empty="1"/>
		<inp2:m_RenderElement name="inp_edit_box" prefix="promo-block" field="ExternalLink"/>
		<inp2:m_RenderElement name="inp_edit_checkbox" prefix="promo-block" field="OpenInNewWindow"/>

		<inp2:m_RenderElement design="form_row" caption_render_as="date_field_caption_element" prefix="promo-block" field="ScheduleFromDate" title="la_fld_ScheduleDate" to_field="ScheduleToDate">
			<td class="control-cell">
				<inp2:m_Phrase label="la_From"/>
				<input type="text" name="<inp2:{$prefix}_InputName field="{$field}_date"/>" id="<inp2:{$prefix}_InputName field="{$field}_date"/>" value="<inp2:{$prefix}_Field field="{$field}_date" format="_regional_InputDateFormat"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:{$prefix}_Format field="{$field}_date" input_format="1" edit_size="edit_size"/>" datepickerIcon="<inp2:m_ProjectBase/>core/admin_templates/img/calendar_icon.gif">&nbsp;
				<img src="img/calendar_icon.gif" id="cal_img_<inp2:{$prefix}_InputName field="{$field}"/>"
						     style="cursor: pointer; margin-right: 5px"
						     title="Date selector"
						/>

				<script type="text/javascript">
					Calendar.setup({
				        inputField		:	"<inp2:{$prefix}_InputName field="{$field}_date"/>",
				        ifFormat		:	Calendar.phpDateFormat("<inp2:{$prefix}_Format field="{$field}_date" input_format="1"/>"),
				        button			:	"cal_img_<inp2:{$prefix}_InputName field="{$field}"/>",
				        align			:	"br",
				        singleClick		:	true,
				        showsTime		:	true,
				        weekNumbers		:	false,
				        firstDay		:	<inp2:m_GetConfig var="FirstDayOfWeek"/>,
				        onUpdate	:	function(cal) {
				        	runOnChange('<inp2:$prefix_InputName field="{$field}_date"/>');
				       	}
					});
				</script>
				<input type="hidden" name="<inp2:{$prefix}_InputName field="{$field}_time"/>" id="<inp2:{$prefix}_InputName field="{$field}_time" input_format="1"/>" value="">


				<inp2:m_Phrase label="la_To"/>
				<input type="text" name="<inp2:{$prefix}_InputName field="{$to_field}_date"/>" id="<inp2:{$prefix}_InputName field="{$to_field}_date"/>" value="<inp2:{$prefix}_Field field="{$to_field}_date" format="_regional_InputDateFormat"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:{$prefix}_Format field="{$to_field}_date" input_format="1" edit_size="edit_size"/>" datepickerIcon="<inp2:m_ProjectBase/>core/admin_templates/img/calendar_icon.gif">&nbsp;
				<img src="img/calendar_icon.gif" id="cal_img_<inp2:{$prefix}_InputName field="{$to_field}"/>"
						     style="cursor: pointer; margin-right: 5px"
						     title="Date selector"
						/>

				<script type="text/javascript">
					Calendar.setup({
				        inputField		:	"<inp2:{$prefix}_InputName field="{$to_field}_date"/>",
				        ifFormat		:	Calendar.phpDateFormat("<inp2:{$prefix}_Format field="{$to_field}_date" input_format="1"/>"),
				        button			:	"cal_img_<inp2:{$prefix}_InputName field="{$to_field}"/>",
				        align			:	"br",
				        singleClick		:	true,
				        showsTime		:	true,
				        weekNumbers		:	false,
				        firstDay		:	<inp2:m_GetConfig var="FirstDayOfWeek"/>,
				        onUpdate	:	function(cal) {
				        	runOnChange('<inp2:$prefix_InputName field="{$to_field}_date"/>');
				       	}
					});
				</script>
				<input type="hidden" name="<inp2:{$prefix}_InputName field="{$to_field}_time"/>" id="<inp2:{$prefix}_InputName field="{$to_field}_time" input_format="1"/>" value="">

			</td>
		</inp2:m_RenderElement>

		<inp2:m_RenderElement name="inp_edit_checkbox" prefix="promo-block" field="Sticky"/>

		<inp2:m_ifnot check="promo-block_IsNewItem">
			<inp2:m_RenderElement name="inp_label" prefix="promo-block" field="NumberOfClicks"/>
			<inp2:m_RenderElement name="inp_label" prefix="promo-block" field="NumberOfViews"/>
			<inp2:m_RenderElement name="inp_label" prefix="promo-block" field="ConversionPercent"/>
		</inp2:m_ifnot>

		<inp2:m_RenderElement name="inp_edit_filler"/>
	</table>
</div>

<script type="text/javascript">
	var otpl = document.getElementById('<inp2:promo-block_InputName field="LinkType"/>');
	var orow_category = document.getElementById('<inp2:promo-block_InputName field="CategoryId"/>').parentNode.parentNode;
	var orow_external_link = document.getElementById('<inp2:promo-block_InputName field="ExternalLink"/>').parentNode.parentNode;
	var orow_open_in_new_window = document.getElementById('<inp2:promo-block_InputName field="OpenInNewWindow"/>').parentNode.parentNode;

	function select_link_type() {
		if (otpl.value == 1) {
			// internal
			orow_category.style.display = '';
			orow_external_link.style.display = 'none';
			orow_open_in_new_window.style.display = 'none';
		} else {
			// external
			orow_category.style.display = 'none';
			orow_external_link.style.display = '';
			orow_open_in_new_window.style.display = '';
		}
	}

	select_link_type();
</script>

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