{template header}

<!--{if empty($infloat)}-->
	{subtemplate header_nofloat}
<!--{/if}-->

<div id="floatlayout_magics" class="float">
	<div class="floatboxnarrow" <!--{if $operation == 'use'}-->style="height:215px"<!--{elseif in_array($operation, array('give', 'drop', 'sell'))}-->style="height:165px"<!--{/if}-->>
		<h3 class="float_ctrl">
			<em>
			<!--{if $operation == 'buy'}-->
				{lang magics_operation_buy}
			<!--{elseif $operation == 'give'}-->
				{lang magics_operation_present}
			<!--{elseif $operation == 'drop'}-->
				{lang magics_operation_drop}
			<!--{elseif $operation == 'sell'}-->
				{lang magics_operation_sell}
			<!--{elseif $operation == 'use'}-->
				{lang magics_operation_use}
			<!--{/if}-->
			</em>
			<span><!--{if !empty($infloat)}--><a title="{lang close}" onclick="floatwin('close_magics')" class="float_close" href="javascript:;">{lang close}</a><!--{/if}--></span>
		</h3>
		<div class="postbox"><em id="return_magics"></em></div>
		<form id="magicform" method="post" action="magic.php?action=index&infloat=yes" onsubmit="ajaxpost('magicform', 'return_magics', 'return_magics', 'onerror');return false;">
			<div class="postbox">
				<input type="hidden" name="formhash" value="{FORMHASH}" />
				<input type="hidden" name="handlekey" value="magics" />
				<input type="hidden" name="operation" value="$operation" />
				<input type="hidden" name="magicid" value="$magicid" />
				<!--{if $operation == 'buy'}-->
					<div class="magicmain">
						<table cellspacing="0" cellpadding="0" class="magicinfo">
							<tr>
								<td width="55%"><h5>$magic[name]</h5></td>
							</tr>

							<tr><td>{lang magics_weight}: $magic[weight]&nbsp;&nbsp;{lang magics_price}: <span class="magicprice">$magic[price]</span> $extcredits[$creditstransextra[3]][title]</td></tr>
							<tr><td><!--{if $useperm}--><span class="magic_yes">{lang magics_permission_yes}</span><!--{else}--><span class="magic_no">{lang magics_permission_no}</span><!--{/if}-->{lang magics_item}</td></tr>
						</table>
						<!--{if $magic[type] == 1}-->
							<p>{lang magics_permission_forum}: </p>
							<p><!--{if $forumperm}-->$forumperm<!--{else}--> {lang magics_permission_allforum} <!--{/if}--></p>
						<!--{/if}-->
						<!--{if $magic[type] == 2}-->
							<p>{lang magics_permission_group}: </p>
							<p><!--{if $targetgroupperm}-->$targetgroupperm<!--{else}--> {lang magics_permission_allgroup} <!--{/if}--></p>
						<!--{/if}-->
					</div>
					<div class="magicnum">
						{lang magics_amount_buy}: <input name="magicnum" type="text" size="2" value="1" class="txt" />&nbsp;
						<!--{if $allowmagics > 1 }-->
							<input type="checkbox" name="checkgive" id="checkgive" value="0" onclick="$('showgive').style.display = $('showgive').style.display == 'none' ? '' : 'none'; this.value = this.value == 0 ? 1 : 0; this.checked = this.value == 0 ? false : true" /> <label for="checkgive">{lang magics_shop_present}</label>
							<p id="showgive" style="display:none">
								{lang magics_target_present}: <input name="tousername" type="text" size="12" class="txt" />
							</p>
						<!--{/if}-->
					</div>
					<input type="hidden" name="operatesubmit" value="yes" />
					<button class="submit fixedbtn" type="submit" name="operatesubmit" id="operatesubmit" value="true" tabindex="101">{lang magics_operation_buy}</button>
				<!--{elseif $operation == 'give'}-->
					<div class="magicnum">
						<p>{lang magics_num}: <input name="magicnum" type="text" size="12" value="1" class="txt" /></p>
						<!--{if $allowmagics > 1 }-->
							<p>{lang magics_target_present}: <input name="tousername" type="text" size="12" class="txt" /></p>
						<!--{/if}-->
					</div>
					<input type="hidden" name="operatesubmit" value="yes" />
					<button class="submit fixedbtn" type="submit" name="operatesubmit" id="operatesubmit" value="true"  onclick="return confirm('{lang magics_confirm}');">{lang magics_operation_present}</button>
				<!--{elseif $operation == 'use'}-->
					<select name="magicid" onchange="floatwin('open_magics', 'magic.php?action=index&operation=use&infloat=yes&magicid='+this.options[this.selectedIndex].value, 250, 215)" class="chosemagic">
						<option value="0">{lang magics_select}</option>
					<!--{loop $magiclist $magic}-->
						<option value="$magic[magicid]" $magicselect[$magic[magicid]] $magicselect[$magic[magicid]]>$magic[name] - $magic[description]</option>
					<!--{/loop}-->
					</select>
					<!--{if $magicid}-->
							{eval showmagic();}
							<input type="hidden" name="usesubmit" value="yes" />
							<input type="hidden" name="operation" value="use" />
							<input type="hidden" name="magicid" value="$magicid" />
							<button class="submit fixedbtn" type="submit" name="usesubmit" id="usesubmit" value="true">{lang magics_operation_use}</button>
					<!--{/if}-->
				<!--{elseif $operation == 'sell'}-->
					<h5 class="magicnum">$magic[name]</h5>
					<p>{lang magics_num}: <input name="magicnum" type="text" size="5" value="1" class="txt" /> {lang magics_price}: <input name="price" type="text" size="5" class="txt" /></p>
					<input type="hidden" name="operatesubmit" value="yes" />
					<button class="submit fixedbtn" type="submit" name="operatesubmit" id="operatesubmit" value="true"  onclick="return confirm('{lang magics_confirm}');">{lang magics_operation_sell}</button>
				<!--{elseif $operation == 'drop'}-->
					<div class="magicnum">
						<p>{lang magics_num}: <input name="magicnum" type="text" size="12" value="1" class="txt" /></p>
					</div>
					<input type="hidden" name="operatesubmit" value="yes" />
					<button class="submit fixedbtn" type="submit" name="operatesubmit" id="operatesubmit" value="true"  onclick="return confirm('{lang magics_confirm}');">{lang magics_operation_drop}</button>
				<!--{/if}-->
			</div>
		</form>
	</div>
</div>

<script type="text/javascript" reload="1">
	function messagehandle_magics(key) {
		if(key != 0) {
			$('magicform').style.display = 'none';
			$('return_magics').className = 'onright';
		}
	}
</script>

<!--{if empty($infloat)}-->
	{subtemplate footer_nofloat}
<!--{/if}-->
{template footer}