<?php exit('Access Denied');?>
<!--{template common/header}-->

<!--{if $order && $codes}-->
<div class="header cl">
	<div class="mz"><a href="javascript:history.back();"><i class="dm-c-left"></i></a></div>
	<h2>{lang invitecode_succeed_title}</h2>
	<div class="my"><a href="index.php"><i class="dm-house"></i></a></div>
</div>
<form name="confirmform" method="get" autocomplete="off" action="member.php">
	<input type="hidden" name="mod" value="{$_G[setting][regname]}" />
	<input type="hidden" name="invitecode" value="{$codes[0]}" />
	<div class="post_box">
		<ul>
			<li class="mtext">
				<textarea class="pt" readonly>{$codetext}</textarea>
			</li>
			<li class="text-muted">{lang invitecode_email}</li>
		</ul>
	</div>
	<div class="post_btn">
		<button class="pn btn_pn mgrey">
			{lang reg_continue}
		</button>
	</div>
</form>
<!--{else}-->
<div class="header cl">
	<div class="mz"><a href="javascript:history.back();"><i class="dm-c-left"></i></a></div>
	<h2>{lang invitecode_buycode}</h2>
	<div class="my"><a href="index.php"><i class="dm-house"></i></a></div>
</div>

<form id="confirmform" name="confirmform" method="post" autocomplete="off" action="misc.php?mod=buyinvitecode">
	<input type="hidden" name="formhash" value="{FORMHASH}" />
	<input type="hidden" name="buysubmit" value="true" />
	<input type="hidden" name="handlekey" value="buyinvite" />
	<div class="post_box p10">
		<ul>
			<!--{if $_G['setting']['inviteconfig']['invitecodeprompt']}-->
			<li class="mtext">
				{$_G['setting'][inviteconfig][invitecodeprompt]}
			</li>
			<!--{/if}-->
			<li class="mli">
				<input type="number" value="" class="px" autocomplete="off" id="amount" name="amount" placeholder="{lang buy_nums}">
			</li>
			<li class="mli">
				<input type="email" value="" class="px" autocomplete="off" name="email" placeholder="{lang active_email}">
			</li>
			<li class="text-muted">{lang active_email_comment}</li>
			<li class="mli b0">
				{lang invitecode_expiration}
				<span class="input-append">$maxinviteday</span>
			</li>
		</ul>
	</div>
	<div class="post_btn">
		<button id="buysubmit_btn" class="pn btn_pn mgrey">
			{lang need_money} <strong id="desamount" class="xi1">0.00</strong> {lang money_unit}
		</button>
	</div>
</form>
<script type="text/javascript">
	(function() {
		// 获取输入框元素
		const amountInput = document.getElementById('amount');
		// 获取显示金额的元素
		const desAmountElement = document.getElementById('desamount');
		// 获取邀请码单价
		const inviteCodePrice = $_G['setting']['inviteconfig']['invitecodeprice'];

		// 为输入框添加 input 事件监听器
		amountInput.addEventListener('input', function() {
			// 去除输入值开头的 0
			let amount = this.value.replace(/^0/, '');
			// 将输入值转换为整数
			amount = parseInt(amount, 10);
			// 计算并更新显示的金额
			desAmountElement.innerHTML = !isNaN(amount) ? (amount * inviteCodePrice).toFixed(2) : '0.00';
		});
	})();
</script>
<!--{/if}-->

<!--{template common/footer}-->