
<form name="formular" enctype="multipart/form-data" action="index.php?p=misc&amp;do=attachment&amp;action=upload" method="post">
  <input id="count" type="hidden" name="count" value="{$maxattachment}" />
  <table width="100%" border="0" cellpadding="2" cellspacing="1" class="box_inner">
    <tr>
      <td class="box_innerhead">{$lang.f_field_attachment}</td>
    </tr>
    {if $smarty.request.left!= ""} {assign var=acount value=$smarty.request.left} {else} {assign var=acount value=$maxattachment} {/if} {section name="file" loop=$acount}
    <tr class="{cycle name="att" values="row_second,row_first"}">
      <td><input type="file" name="attachment[]" />
      </td>
    </tr>
    {/section}
    <tr>
      <td><input class="button" type="submit" value="{$lang.f_btn_upload}" /> 
	  {if $smarty.request.toid != ""}
	  <input name="toid" type="hidden" id="toid" value="{$smarty.request.toid}">
	  {else}
	  <input name="fid" type="hidden" id="fid" value="{$smarty.request.fid}">
	  {/if}
	  </td>
    </tr>
  </table>
</form>
<p>
	{foreach from=$allowed_files item=allowed_file}
	<li>{$allowed_file->filetype}: {$allowed_file->filesize} Kb</li>
	{/foreach}
</p>

<p> {foreach from=$files item=file}{if $file.forbidden}
<script>
alert('{$file.reason} {$file.orig_name}');
window.close();
</script>
<li>{$file.reason} {$file.orig_name}</li>
{else}

<li>
<a href="index.php?p=forum&amp;action=showfile={$file.id}">{$file.orig_name}</a>
</li>
<script language="javascript" type="text/javascript">
		var hiddenField = document.createElement("input");
		hiddenField.type = "hidden";
		hiddenField.name = "attachment[]";
		hiddenField.value = "{$file.id}";

		var fileCount = opener.document.getElementById("hidden_count");
		
		if (fileCount.value < {$maxattachment}) {ldelim}
			fileCount.value++;
			//opener.document.getElementById("fileCount").value = opener.document.getElementById("fileCount").value + 1;
			opener.document.getElementById("attachments").innerHTML += 
				"<input id='files' type='hidden' name='attach_hidden[]' value='{$file.id}' />" +
				"&bull; {$file.orig_name}<br />";
		{rdelim}
	</script>
	{if $smarty.request.action=="upload"}
<script>
   window.close();
</script>
{/if}
{/if}
{/foreach}
</p>
<p><a href="javascript:close()">{$lang.forum_links_close}</a></p>
