<!-- BEGIN attach -->

<!-- BEGIN denyrow -->
<fieldset class="attach">
<legend>{TOPIC_ATTACH_ICON} {L_ATTACHMENT}</legend>
	<p class="attach_link denied">{postrow.attach.denyrow.L_DENIED}</p>
</fieldset>

<!-- END denyrow -->

<!-- BEGIN cat_images -->
<fieldset class="attach">
<legend>{TOPIC_ATTACH_ICON} {L_ATTACHMENT} ({postrow.attach.cat_images.FILESIZE})</legend>
	<p class="tCenter pad_6">
		<img src="{postrow.attach.cat_images.IMG_SRC}" id="attachImg" class="postImg" alt="img" border="0" />
	</p>
	<!-- IF postrow.attach.cat_images.COMMENT -->
	<p class="tCenter med lh_110">
		{postrow.attach.cat_images.COMMENT}
	</p>
	<!-- ENDIF -->
</fieldset>

<!-- END cat_images -->

<!-- BEGIN cat_thumb_images -->
<fieldset class="attach">
<legend>{TOPIC_ATTACH_ICON} {L_ATTACHMENT_THUMBNAIL}</legend>
	<p class="attach_link">
		<a href="{postrow.attach.cat_thumb_images.IMG_SRC}" target="_blank"><img src="{postrow.attach.cat_thumb_images.IMG_THUMB_SRC}" alt="{postrow.attach.cat_thumb_images.DOWNLOAD_NAME}" border="0" /></a>
	</p>
	<p class="attach_link">
		<a href="{postrow.attach.cat_thumb_images.IMG_SRC}" target="_blank"><b>{postrow.attach.cat_thumb_images.DOWNLOAD_NAME}</b></a>
		<span class="attach_stats med">({postrow.attach.cat_thumb_images.FILESIZE})</span>
	</p>
	<!-- IF postrow.attach.cat_thumb_images.COMMENT -->
	<p class="attach_comment med">
		{postrow.attach.cat_thumb_images.COMMENT}
	</p>
	<!-- ENDIF -->
</fieldset>

<!-- END cat_thumb_images -->

<!-- BEGIN attachrow -->
<fieldset class="attach">
<legend>{postrow.attach.attachrow.S_UPLOAD_IMAGE} {L_ATTACHMENT}</legend>
	<p class="attach_link">
		<a href="{postrow.attach.attachrow.U_DOWNLOAD_LINK}" {postrow.attach.attachrow.TARGET_BLANK}><b>{postrow.attach.attachrow.DOWNLOAD_NAME}</b></a>
		<span class="attach_stats med">({postrow.attach.attachrow.FILESIZE}, {L_DOWNLOADED}: {postrow.attach.attachrow.DOWNLOAD_COUNT})</span>
	</p>
	<!-- IF postrow.attach.attachrow.COMMENT -->
	<p class="attach_comment med">
		{postrow.attach.attachrow.COMMENT}
	</p>
	<!-- ENDIF -->
</fieldset>

<!-- END attachrow -->

<!-- BEGIN tor_not_reged -->
<div class="nav-tabs-custom" style="clear: both;">
<ul class="nav nav-tabs">
	<li class="active"><a data-toggle="tab" href="#attach">{postrow.attach.tor_not_reged.DOWNLOAD_NAME}</a></li>
</ul>
<div class="tab-content">
	<div id="attach" class="tab-pane active">

		<div class="row">
		<div class="col-sm-6 col-xs-12 form-horizontal">
			<dl class="dl-horizontal">
				<dt>{L_TORRENT}:</dt>
				<dd>{postrow.attach.tor_not_reged.TRACKER_LINK}</dd>
				<dt>{L_ADDED}:</dt>
				<dd>{postrow.attach.tor_not_reged.POSTED_TIME}</dd>
				<dt>{L_DOWNLOADED}:</dt>
				<dd>{postrow.attach.tor_not_reged.DOWNLOAD_COUNT} <!-- IF SHOW_DL_LIST_LINK -->&nbsp;[ <a href="{DL_LIST_HREF}" class="med">{L_SHOW_DL_LIST}</a> ] <!-- ENDIF --></dd>
				<!-- BEGIN comment -->
				<dt>{L_FILE_COMMENT}:</dt>
				<dd>{postrow.attach.tor_not_reged.comment.COMMENT}</dd>
				<!-- END comment -->
			</dl>

			<script type="text/javascript">
			ajax.callback.change_torrent = function(data) {
				if(data.title) alert(data.title);
				if(data.url) document.location.href = data.url;
			};
			</script>
			<!-- IF TOR_CONTROLS -->
			<script type="text/javascript">
			function change_torrents()
			{
				ajax.exec({
					action    : 'change_torrent',
					attach_id : {postrow.attach.tor_not_reged.ATTACH_ID},
					type      : $('#tor-select-{postrow.attach.tor_not_reged.ATTACH_ID}').val(),
				});
			}
			</script>
			<div class="input-group">
				<select name="tor_action" class="form-control" id="tor-select-{postrow.attach.tor_not_reged.ATTACH_ID}" onchange="$('#tor-confirm-{postrow.attach.tor_not_reged.ATTACH_ID}').attr('checked', false); $('#tor-submit-{postrow.attach.tor_not_reged.ATTACH_ID}').attr('disabled', true)">
					<option value="" selected="selected" class="select-action">&raquo; {L_SELECT_ACTION}</option>
					<option value="del_torrent">{L_DELETE_TORRENT}</option>
					<option value="del_torrent_move_topic">{L_DELETE_MOVE_TORRENT}</option>
				</select>
				<span class="input-group-btn">
					<a href="#" onclick="change_torrents($('#tor-{postrow.attach.tor_reged.ATTACH_ID} select').val()); return false;"><input type="submit" value="{L_SUBMIT}" class="btn btn-default btn-flat" /></a>
				</span>
			</div>
			<!-- ENDIF -->

		</div>

		<div class="col-sm-6 col-xs-12">
			<div class="info-box">
				<span class="info-box-icon bg-green"><i class="fa fa-fw fa-download"></i></span>

				<div class="info-box-content">
					<span class="info-box-text">{L_SIZE}: {postrow.attach.tor_not_reged.FILESIZE}</span>
					<span class="info-box-text">{L_TORRENT}: {L_BT_REG_NO}</span>
				</div>
			</div>
		</div>
		</div>

	</div>
</div>
</div>

<!-- END tor_not_reged -->

<!-- BEGIN tor_reged -->

<!-- IF TOR_BLOCKED -->
<div class="callout callout-danger">
	<p>{TOR_BLOCKED_MSG}</p>
</div>
<!-- ELSE -->
<!-- IF SHOW_RATIO_WARN -->
<div class="callout callout-warning">
	<p>{RATIO_WARN_MSG}</p>
</div>
<!-- ENDIF -->
<!-- IF AUTH_MOD -->
<div class="modal fade" id="attach__{postrow.attach.tor_reged.ATTACH_ID}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
	<div class="modal-content">
		<div class="modal-header">
			<button aria-label="Close" data-dismiss="modal" class="close" type="button">
			<span aria-hidden="true">×</span></button>
			<h4 class="modal-title">{L_TOR_STATUS}</h4>
		</div>
		<div class="modal-body">
				<!-- IF postrow.attach.tor_reged.TOR_STATUS_REPLY || AUTH_MOD -->
				<div class="form-group">
				<script type="text/javascript">
					ajax.change_tor_status = function(mode) {
						ajax.exec({
							action    : 'change_tor_status',
							attach_id : {postrow.attach.tor_reged.ATTACH_ID},
							mode      : mode,
							status    : $('#sel_status').val(),
							comment   : $('#comment').val(),
						});
					};
					ajax.callback.change_tor_status = function(data) {
					<!-- IF AUTH_MOD -->
						$('#tor-'+ data.attach_id +'-status').html(data.status);
					<!-- ELSEIF postrow.attach.tor_reged.TOR_STATUS_REPLY -->
						$('#tor_comment').html('{L_TOR_AUTH_SENT_COMMENT}');
					<!-- ENDIF -->
						$('#comment').attr('value', '');
					};
				</script>
				<label>{L_COMMENT}</label>
				<span id="tor_comment">
				<!-- IF $bb_cfg['tor_comment'] -->
				<input type="text" id="comment" class="form-control" placeholder="{L_COMMENT}" />
				<!-- ENDIF -->
				</span>
				</div>
			<label>{L_TOR_STATUS}</label>
			<div class="input-group">
				<!-- IF AUTH_MOD -->
				<span id="tor-{postrow.attach.tor_reged.ATTACH_ID}">{postrow.attach.tor_reged.TOR_STATUS_SELECT}</span>
				<div class="input-group-btn">
				<a href="#" onclick="ajax.change_tor_status('status'); return false;" data-dismiss="modal"><input type="submit" value="{L_EDIT}" class="btn btn-default btn-flat" /></a>
				</div>
				<!-- ELSEIF postrow.attach.tor_reged.TOR_STATUS_REPLY -->
				<a href="#" onclick="ajax.change_tor_status('status_reply'); return false;"><input type="submit" value="{L_TOR_AUTH_FIXED}" class="btn btn-default btn-flat" /></a>
				<!-- ENDIF -->
			</div>
				<!-- ENDIF / AUTH_MOD -->
		</div>
	</div>
</div>
</div>
<!-- ENDIF -->

<div class="nav-tabs-custom" style="clear: both;">

<ul class="nav nav-tabs">
	<li class="active"><a data-toggle="tab" href="#attach" aria-expanded="false">
		<span class="{postrow.attach.tor_reged.DL_TITLE_CLASS}">{postrow.attach.tor_reged.DOWNLOAD_NAME}</span>
		<!-- IF postrow.attach.tor_reged.TOR_SILVER_GOLD == 2 && $tr_cfg['gold_silver_enabled'] -->
		<img src="styles/images/tor_silver.gif" width="16" height="15" title="{L_SILVER}" />&nbsp;{L_SILVER_STATUS}&nbsp;<img src="styles/images/tor_silver.gif" width="16" height="15" title="{L_SILVER}" />
		<!-- ELSEIF postrow.attach.tor_reged.TOR_SILVER_GOLD == 1 && $tr_cfg['gold_silver_enabled'] -->
		<img src="styles/images/tor_gold.gif" width="16" height="15" title="{L_GOLD}" />&nbsp;{L_GOLD_STATUS}&nbsp;<img src="styles/images/tor_gold.gif" width="16" height="15" title="{L_GOLD}" />
		<!-- ENDIF -->
	</a></li>
	<li><a data-toggle="tab" href="#tor-filelist-btn" aria-expanded="false">{L_FILELIST}</a></li>
	<li class="pull-right" style="padding: 10px 15px;">
		<span id="tor-{postrow.attach.tor_reged.ATTACH_ID}-status" class="text-muted">{postrow.attach.tor_reged.TOR_STATUS_ICON} <b>{postrow.attach.tor_reged.TOR_STATUS_TEXT}</b>
		<!-- IF postrow.attach.tor_reged.TOR_STATUS_BY -->{postrow.attach.tor_reged.TOR_STATUS_BY}<!-- ENDIF -->
		<!-- IF postrow.attach.tor_reged.TOR_STATUS_REPLY || AUTH_MOD -->
		<a data-target="#attach__{postrow.attach.tor_reged.ATTACH_ID}" data-toggle="modal" class="text-muted"><i class="fa fa-gear"></i></a>
		<!-- ENDIF -->
		</span>
	</li>
</ul>

<div class="tab-content">
	<div id="attach" class="tab-pane active">
	<div class="row">
	<div class="col-sm-6 col-xs-12 form-horizontal">
		<dl class="dl-horizontal">
			<dt>{L_TORRENT}:</dt>
			<dd>{postrow.attach.tor_reged.TRACKER_LINK} [ <span title="{postrow.attach.tor_reged.REGED_DELTA}">{postrow.attach.tor_reged.REGED_TIME}</span> ]</dd>
			<dt>HASH:</dt>
			<dd>{postrow.attach.tor_reged.HASH}</dd>
			<!-- BEGIN comment -->
			<dt>{L_FILE_COMMENT}:</dt>
			<dd>{postrow.attach.tor_reged.comment.COMMENT}</dd>
			<!-- END comment -->
		</dl>

		<script type="text/javascript">
		ajax.callback.change_torrent = function(data) {
			if (data.title) alert(data.title);
			if (data.url) document.location.href = data.url;
		};
		</script>
		<!-- IF TOR_CONTROLS -->
		<script type="text/javascript">
		function change_torrents()
		{
			ajax.exec({
				action    : 'change_torrent',
				attach_id : {postrow.attach.tor_reged.ATTACH_ID},
				type      : $('#tor-select-{postrow.attach.tor_reged.ATTACH_ID}').val(),
			});
		}
		</script>
		<div class="input-group">
			<select class="form-control" name="tor_action" id="tor-select-{postrow.attach.tor_reged.ATTACH_ID}" onchange="$('#tor-confirm-{postrow.attach.tor_reged.ATTACH_ID}').attr('checked', false); $('#tor-submit-{postrow.attach.tor_reged.ATTACH_ID}').attr('disabled', true)">
				<option value="" selected="selected" class="select-action">&raquo; {L_SELECT_ACTION}</option>
				<option value="del_torrent">{L_DELETE_TORRENT}</option>
				<option value="del_torrent_move_topic">{L_DELETE_MOVE_TORRENT}</option>
				<!-- IF AUTH_MOD -->
				<!-- IF $tr_cfg['gold_silver_enabled'] -->
				<!-- IF postrow.attach.tor_reged.TOR_SILVER_GOLD == 1 -->
				<option value="unset_silver_gold">{L_UNSET_GOLD_TORRENT} / {L_UNSET_SILVER_TORRENT}</option>
				<option value="set_silver">{L_SET_SILVER_TORRENT}</option>
				<!-- ELSEIF postrow.attach.tor_reged.TOR_SILVER_GOLD == 2 -->
				<option value="unset_silver_gold">{L_UNSET_GOLD_TORRENT} / {L_UNSET_SILVER_TORRENT}</option>
				<option value="set_gold">{L_SET_GOLD_TORRENT}</option>
				<!-- ELSE -->
				<option value="set_gold">{L_SET_GOLD_TORRENT}</option>
				<option value="set_silver">{L_SET_SILVER_TORRENT}</option>
				<!-- ENDIF -->
				<!-- ENDIF -->
				<!-- ENDIF -->
			</select>
			<span class="input-group-btn">
			<a href="#" onclick="change_torrents($('#tor-{postrow.attach.tor_reged.ATTACH_ID} select').val()); return false;"><input type="submit" value="{L_EDIT}" class="btn btn-default btn-flat" /></a>
			</span>
		</div>
		<!-- ELSEIF TOR_HELP_LINKS -->
		<a class="text-aqua" href="{TOR_HELP_LINKS}">{L_TERMS}</a>
		<!-- ELSE -->
		&nbsp;
		<!-- ENDIF -->
	</div>

	<div class="col-sm-6 col-xs-12">
		<div class="info-box">
			<span class="info-box-icon bg-green">
			<!-- IF postrow.attach.tor_reged.TOR_FROZEN -->
			<i class="fa fa-fw fa-download"></i>
			<!-- ELSE -->
			<a href="{postrow.attach.tor_reged.U_DOWNLOAD_LINK}" class="text-white" title="{L_DOWNLOAD}">
			<i class="fa fa-fw fa-download"></i></a>
			<!-- ENDIF -->
			</span>

			<div class="info-box-content">
				<span class="info-box-text">{L_SIZE}: {postrow.attach.tor_reged.TORRENT_SIZE}</span>
				<span class="info-box-text" title="{L_DOWNLOADED}: {postrow.attach.tor_reged.DOWNLOAD_COUNT}">{L_COMPLETED}: {postrow.attach.tor_reged.COMPLETED}</span>
			</div>
		</div>
		<!-- IF postrow.attach.tor_reged.TOR_FROZEN == 0 --><!-- IF MAGNET_LINKS -->
		<div class="info-box">
			<span class="info-box-icon bg-aqua">{postrow.attach.tor_reged.MAGNET}</span>

			<div class="info-box-content">
				<span class="info-box-text">magnet</span>
			</div>
		</div>
		<!-- ENDIF --><!-- ENDIF -->
	</div>
	</div>
	</div>

	<div id="tor-filelist-btn" class="tab-pane">
		<input id="tor-filelist-btn" type="button" class="lite" value="{L_FILELIST}" />
		<div id="tor-fl-wrap" style="display: none;>
		<div id="fl-tbl-wrap">
			<table class="table" cellspacing="0" cellpadding="0">
			<tr>
				<td>
					<div id="tor-fl-treecontrol">
						<a href="#">{L_COLLAPSE}</a>&middot;
						<a href="#">{L_EXPAND}</a>&middot;
						<a href="#">{L_SWITCH}</a>
					</div>
				</td>
			</tr>
			<tr>
				<td class="vTop" style="width: 100%;"><div id="tor-filelist"><span class="loading-1">{L_LOADING}</span></div></td>
			</tr>
			</table>
		</div>
		</div>
	</div>

</div>

<script type="text/javascript">
function humn_size (size) {
	var i = 0;
	var units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
	while ((size/1024) >= 1) {
		size = size/1024;
		i++;
	}
	size = new String(size);
	if (size.indexOf('.') != -1) {
		size = size.substring(0, size.indexOf('.') + 3);
	}
	return size + ' ' + units[i];
}

ajax.tor_filelist_loaded = false;
$('#tor-filelist-btn').click(function(){
	if (ajax.tor_filelist_loaded) {
		$('#tor-fl-wrap').toggle();
		return false;
	}
	$('#tor-fl-wrap').show();

	ajax.exec({action: 'view_torrent', attach_id: {postrow.attach.tor_reged.ATTACH_ID} });
	ajax.callback.view_torrent = function(data) {
		$('#tor-filelist').html(data.html);
		$('#tor-filelist > ul.tree-root').treeview({
			control: "#tor-fl-treecontrol"
		});
		$('#tor-filelist li.collapsable').each(function(){
			var $li = $(this);
			var dir_size = 0;
			$('i', $li).each(function(){ dir_size += parseInt(this.innerHTML) });
			$('span.b:first', $li).append(' &middot; <s>' + humn_size(dir_size) + '</s>');
		});
		$('#tor-filelist i').each(function(){
			var size_bytes = this.innerHTML;
			this.innerHTML = '('+ size_bytes +')';
			$(this).prepend('<s>'+ humn_size(size_bytes) +'</s> ');
		});
		ajax.tor_filelist_loaded = true;
	};
	$('#tor-fl-treecontrol a').click(function(){ this.blur(); });
	return false;
});
</script>

<style type="text/css">
#tor-fl-wrap {
	margin: 12px auto 0; width: 95%;
}
#fl-tbl-wrap { margin: 2px 14px 16px 14px; }
#tor-filelist {
	margin: 0 2px; padding: 8px 6px;
	max-height: 284px; overflow: auto;
}
#tor-filelist i { color: #7A7A7A; padding-left: 4px; }
#tor-filelist s { color: #0000FF; text-decoration: none; }
#tor-filelist .b > s { color: #800000; }
#tor-filelist .b { font-weight: bold; padding-left: 20px; background: transparent url('styles/images/folder.gif') no-repeat 3px 50%;}
#tor-filelist ul li span { padding-left: 20px; background: transparent url('styles/images/page.gif') no-repeat 3px 50%;}
#tor-filelist .tor-root-dir { font-size: 13px; font-weight: bold; line-height: 12px; padding-left: 4px; }
#tor-fl-treecontrol { padding: 2px 0 4px; }
#tor-fl-treecontrol a { padding: 0 8px; font-size: 11px; text-decoration: none; }
#tor-fl-bgn { width: 200px; height: 300px; margin-right: 6px; border: 1px solid #B5BEC4;}
</style>

<!-- ENDIF -->
<!-- END tor_reged -->

<!-- END attach -->