<script type="text/javascript" charset="utf-8">
function xoonipsDownloadConfirmation(file_id) {
	// overlay
	jQuery('#<{$dirname}>_overlay').css({height:jQuery(document).height() + 'px', display:'block'});
	
	// lightbox
	var top = (window.pageYOffset || document.documentElement.scrollTop || 0) + (jQuery(window).height() / 15);
	jQuery('#<{$dirname}>_lightbox').css({top:top + 'px', display:'block'});
	
	// initialize controls
	var form = jQuery('#<{$dirname}>_downloadform_' + file_id);
	if (form.find(':radio[name="radio_notify"]').length > 0) {
		form.find(':radio[name="radio_notify"]').eq(1).attr('checked', true);
	}
	if (form.find(':radio[name="radio_license"]').length > 0) {
		form.find(':radio[name="radio_license"]').eq(1).attr('checked', true);
	}
	form.find(':submit[name="download"]').attr('disabled', 'disabled');

	<{foreach item=file from=$files}>
		var page = jQuery('#<{$dirname}>_download_page_' + <{$file.fileID}>);
		if (page.length > 0) {
			if (<{$file.fileID}> == file_id) {
				page.css('display', 'block');
			} else {
				page.css('display', 'none');
			}
		}
	<{/foreach}>
	return false;
}
function xoonipsChangeDownloadEnabled(file_id) {
	var form = jQuery('#<{$dirname}>_downloadform_' + file_id);
	if ((form.find(':radio[name="radio_notify"]').length > 0
			&& form.find(':radio[name="radio_notify"][checked]').val() == 0)
		|| (form.find(':radio[name="radio_license"]').length > 0
			&& form.find(':radio[name="radio_license"][checked]').val() == 0)) {
		form.find(':submit[name="download"]').attr('disabled', 'disabled');
	} else {
		form.find(':submit[name="download"]').removeAttr('disabled');
	}
	return true;
}
function xoonipsCloseDownloadConfirmation() {
	jQuery('#<{$dirname}>_overlay').hide();
	jQuery('#<{$dirname}>_lightbox').hide();
	return true;
}
</script>
<div style="opacity: 0.8; display: none;" id="<{$dirname}>_overlay">
</div>
<div style="display: none;" id="<{$dirname}>_lightbox">
	<div style="width: 570px;" id="<{$dirname}>_outerImageContainer" >
		<div id="<{$dirname}>_imageContainer">
		<{foreach name='files' item=file from=$files}>
			<div id="<{$dirname}>_download_page_<{$file.fileID}>" style="display: none;" >
			<form action="<{$download_url}>" method="post" onsubmit="xoonipsCloseDownloadConfirmation()" id="<{$dirname}>_downloadform_<{$file.fileID}>">
			<input type="hidden" name="file_id" value="<{$file.fileID}>" />
			<input type="hidden" name="<{$dirname}>_download_with_token" value="1" />
			<{$file.token}>
				<div style="text-align: left">
				<{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_FILE_INFO_TITLE_LABEL}>
					<div class="<{$dirname}>_download_box">
					<{$file.fileName|xoops_escape}><br />
					<table style="width: auto">
					<tr>
						<td><{$smarty.const._MD_XOONIPS_ITEM_TYPE_LABEL}></td>
						<td>: <{$file.mimeType}></td>
					</tr>
					<tr>
						<td><{$smarty.const._MD_XOONIPS_ITEM_SIZE_LABEL}></td>
						<td>: <{$file.fileSizeStr}></td>
					</tr>
					<tr>
						<td><{$smarty.const._MD_XOONIPS_ITEM_LAST_UPDATED_LABEL}></td>
						<td>: <{$file.lastUpdated|date_format:"%b %d, %Y"}></td>
					</tr>
					</table>
					</div>
					<br />
 					<{if $use_license}>
						<{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_LICENSE_TITLE_LABEL}>
						<div class="<{$dirname}>_download_box">
						<{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_LICENSE_QUERY_LABEL}><br />
						<{if $use_cc == '1'}>
							<{$rights}><br />
						<{else}>
							<textarea readonly="readonly" rows="10" cols="60" style="width:480px;"><{$rights|xoops_escape}></textarea><br />
						<{/if}>
						<input type="radio" name="radio_license" value="1" onclick="xoonipsChangeDownloadEnabled(<{$file.fileID}>);" /><{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_LICENSE_YES_LABEL}><br />
						<input type="radio" name="radio_license" value="0" onclick="xoonipsChangeDownloadEnabled(<{$file.fileID}>);" checked="checked" /><{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_LICENSE_NO_LABEL}><br />
						</div>
						<br />
					<{/if}>
					<{if $attachment_dl_notify == '1'}>
						<{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_DL_NOTIFY_TITLE_LABEL}>
						<div class="<{$dirname}>_download_box">
						<{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_DL_NOTIFY_QUERY_LABEL}><br />
						<input type="radio" name="radio_notify" value="1" onclick="xoonipsChangeDownloadEnabled(<{$file.fileID}>);" /><{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_DL_NOTIFY_YES_LABEL}><br />
						<input type="radio" name="radio_notify" value="0" onclick="xoonipsChangeDownloadEnabled(<{$file.fileID}>);" checked="checked" /><{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_DL_NOTIFY_NO_LABEL}><br />
						</div>
						<br />
					<{/if}>
				</div>
			<{if $use_license && $attachment_dl_notify}>
				<{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_NEED_AGREE_BOTH_LABEL}>
			<{else}>
				<{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_NEED_AGREE_LABEL}>
			<{/if}>
			<br />
			<input class="formButton" type="submit" name="download" value="<{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_DOWNLOAD_LABEL}>" disabled="disabled" />
			<input class="formButton" type="button" value="<{$smarty.const._MD_XOONIPS_ITEM_ATTACHMENT_CANCEL_LABEL}>" onclick="xoonipsCloseDownloadConfirmation()" />
			</form>
			</div>
		<{/foreach}>
		</div>
	</div>
</div>
<{/if}>
