{include file="$admingentemplates/admin_top.tpl"}
<font class=red_header>{$lang.settings.razdel_name}</font>
<div class="help_text">
    <div class="close_help">
        <img src="{$site_root}{$template_root}/images/close_help.png" alt="">
    </div>
    <div class="help_body">
        <span class="help_title">{$lang.help}:</span>{$lang.admin.update.help}
    </div>
</div>
<div>
	<table width="100%" border="0">
		<tr>
			<td width="50%" align="left">
				<b>{$lang.admin.update.file_list}</b>
			</td>
			<td width="10%" align="left" >&nbsp;
			</td>
			<td width="40%" align="left">
				<b>{$lang.admin.update.lang_list}</b>
			</td>
		</tr>
		<tr valign="top">
			<td width="50%" align="left" valign="top">
				<table width="100%">
					<tr>
						<td width="10%">
							<input type="checkbox" id="files_all" value="1">
						</td>
						<td width="50%">
							<b>{$lang.admin_reference.select_all}</b>
						</td>
						<td width="40%">
							
						</td>
					</tr>
				{foreach from=$arr_files item=item name=files}
					<tr>
						<td width="10%">
							<input type="checkbox" class="files" id="{$smarty.foreach.files.iteration}" value="1">
						</td>
						<td width="50%">
							<span id="file_{$smarty.foreach.files.iteration}">{$item.name}</span>
						</td>
						<td width="40%">
							<span>{$item.modife}</span>
						</td>
					</tr>
				{/foreach}
				</table>
			</td>
			<td width="10%" align="left" style="border-left: 2px solid #e7e7e7;">&nbsp;
			</td>
			<td width="40%" align="left">
				<table width="100%">
				{foreach from=$arr_langs item=item name=files}
					<tr>
						<td width="10%">
							<input type="checkbox" class="langs" id="lang_{$smarty.foreach.files.iteration}" value="{$item.id}">
						</td>
						<td align="left">
							<span id="lang_{$smarty.foreach.files.iteration}">{$item.file}</span>
						</td>
					</tr>
				{/foreach}
				</table>
			</td>
		</tr>
		<tr style="padding:10px;">
			<td>
				<input type="button" name="ok" value="{$lang.admin.update.button}" onclick="Update();">
			</td>
			<td colspan="2">
				<div id="info">
				</div>
			</td>
		</tr>
	</table>
</div>
<script type="text/javascript">
{literal}
function Update() {
	var default_lang = '{/literal}{$def_lang}{literal}';
	var count_files = $('.files').size();
	var count_langs = $('.langs').size();
	var i;
	var str_files = '';
	var str_langs = '';
	var val;
	var text;
	for (i = 1; i < count_files+1; i++) {
		if ($('#'+i).is(':checked')) {
			text = $('#file_'+i).text();
			if (/(admin).*/.test(text)) text = 'admin.xml';
			if (/(mail\/).*/.test(text)) text = 'mail.xml';
			if(str_files == '') str_files = text;
			else str_files = str_files+','+text;
		}
	}
	for (i = 1; i < count_langs+1; i++) {
		if ($('#lang_'+i).is(':checked')) {
			val = $('#lang_'+i).val();
			if(str_langs == '') str_langs = val;
			else str_langs = str_langs+','+val;
		}
	}
	if (str_langs != '' && str_files != '') {
		ajaxLoadingImage(1, 'info');
		$.post('admin_settings.php',{sel:'update', str_files:str_files, str_langs:str_langs, default_lang:default_lang},
			function (data) {
				ajaxLoadingImage(0, 'info');
				ShowAjaxError(data);
				$('#info').html(data);
			}
		);
	}
}
$(document).ready(function() {
	$('#files_all').click(function () {
		if ($('#files_all').is(':checked'))
			$('.files').attr('checked','checked')
		else 
			$('.files').attr('checked','')
	});
});
{/literal}
</script>

{include file="$admingentemplates/admin_bottom.tpl"}