<?php if (!defined('FLUX_ROOT')) exit; ?>
	<h2>Viewing Item</h2>
	<?php if ($item): ?>
	<?php $icon = $this->iconImage($item->item_id); ?>
	<div style="overflow-x:auto;">
		<table class="vertical-table">
		  <tr >
			<td colspan=10 >
				<p>
					<?php if ($icon): ?><img src="<?php echo $icon ?>" /><?php endif ?>

						#<?php echo htmlspecialchars($item->item_id) ?>: <?php echo htmlspecialchars($item->name) ?>

					<?php if (($item->slots) > 0) : ?>
						[<?php echo number_format((int)$item->slots) ?>]
					<?php endif ?>
							(<?php echo htmlspecialchars($item->identifier) ?>)
				</p>
		  </td>
		 </tr>
		 <tr>
		  <td>Type</td>
		  <td><?php echo $this->itemTypeText($item->type) ?></td>
		  <td>Class</td>
		  <td>
			<?php echo $this->itemTypeText($item->type, $item->view_sprite) ?> 
		  </td>
		  <td>Buy</td>
		  <td><?php echo number_format((int)$item->price_buy) ?></td>
		  <td>Sell</td>
		  <td>
					<?php if (is_null($item->price_sell) && $item->price_buy): ?>
						<?php echo number_format(floor($item->price_buy / 2)) ?>
					<?php else: ?>
						<?php echo number_format((int)$item->price_sell) ?>
					<?php endif ?>

		  </td>
		  <td>Weight</td>
		  <td><?php echo round($item->weight, 1) ?></td>
		 </tr>
		 <tr>

			<?php if (($item->atk) > 0) : ?>
				<td>Atk</td>
				<td><?php echo number_format((int)$item->atk) ?></td>
			<?php else: ?>

				<td>Defense</td>
				<td><?php echo number_format((int)$item->defence) ?></td>
			<?php endif ?>

		  <td>Required Lvl</td>
		  <td><?php echo number_format((int)$item->equip_level_min) ?></td>
		  <td>Refinable</td>
		  <td>
					<?php if ($item->refineable): ?>
						Yes
					<?php else: ?>
						No
					<?php endif ?>

		  </td>
		  <td>Slot</td>
		  <td><?php echo number_format((int)$item->slots) ?></td>
		  <td></td>
		  <td></td>
		 </tr>
		 <tr>
		  <td>Applicable Jobs</td>
		  <td colspan=9>
					<?php if ($jobs=$this->equippableJobs($item->equip_jobs)): ?>
						<?php echo htmlspecialchars(implode(' / ', $jobs)) ?>
					<?php else: ?>
						<span class="not-applicable">None</span>
					<?php endif ?>
		 </td>
		 </tr>

    <?php if(Flux::config('ShowItemDesc')):?>
	<tr>
		<td>Description</td>
		<td colspan=9>
			<?php if($item->itemdesc): ?>
                <?php echo $item->itemdesc ?>
            <?php else: ?>
                <span class="not-applicable">Unknown</span>
			<?php endif ?>
		</td>
	</tr>
<?php endif ?>


		<?php if ($locs=$this->equipLocations($item->equip_locations)): ?>

		 <tr>
			<td>Location</td>
			<td colspan=9>
			<?php echo htmlspecialchars(implode(' + ', $locs)) ?>
			</td>
		 </tr>
		<?php endif ?>
		<?php if (($isCustom && $auth->allowedToSeeItemDb2Scripts) || (!$isCustom && $auth->allowedToSeeItemDbScripts)): ?>
			<tr>
				<td>Item Use Script</td>
				<td colspan=9>
					<?php if ($script=$this->displayScript($item->script)): ?>
						<?php echo $script ?>
					<?php else: ?>
						<span class="not-applicable">None</span>
					<?php endif ?>
				</td>
			</tr>
			<tr>
				<td>Equip Script</td>
				<td colspan=9>
					<?php if ($script=$this->displayScript($item->equip_script)): ?>
						<?php echo $script ?>
					<?php else: ?>
						<span class="not-applicable">None</span>
					<?php endif ?>
				</td>
			</tr>
			<tr>
				<td>Unequip Script</td>
				<td colspan=9>
					<?php if ($script=$this->displayScript($item->unequip_script)): ?>
						<?php echo $script ?>
					<?php else: ?>
						<span class="not-applicable">None</span>
					<?php endif ?>
				</td>
			</tr>
		<?php endif ?>
		<?php if ($itemDrops): ?>
		 <tr>
		  <td>Drop By</td>
		  <td colspan=9>
			<?php foreach ($itemDrops as $itemDrop): ?>
				<?php if ($auth->actionAllowed('monster', 'view_sprite')): ?>
						<?php echo $this->linkToMonster($itemDrop['monster_id'], $itemDrop['monster_name']) ?>
					<?php else: ?>
						<?php echo htmlspecialchars($itemDrop['monster_name']) ?>
					<?php endif ?>

					<?php if ($itemDrop['type'] == 'mvp'): ?>
						<span class="mvp">MVP!</span>
					<?php endif ?>
					
				
					(<strong><?php echo $itemDrop['drop_chance'] ?>%</strong>)
			<?php endforeach ?>

		  </td>
		 </tr>
		<?php endif ?>
		<?php if ($itemobtains): ?>
		 <tr>
		  <td>Obtained from</td>
		  <td colspan=9>
			<?php foreach ($itemobtains as $itemobtain): ?>
				<?php if ($icon=$this->iconImage($itemobtain->id)) ?>
					<img src="<?php echo htmlspecialchars($icon); ?>" />
					<?php if (($itemobtain->id)==732): ?>
						<a href="/?module=quest_db&action=40007">Comodo Gambling</a>
					<?php else: ?>
						<?php echo $this->linkToItem($itemobtain->id,($itemobtain->name_japanese))?>
						(<strong><?php echo $itemobtain->rate ?>%</strong>)


						
					<?php endif ?>	
			<?php endforeach ?>

		  </td>
		 </tr>
		<?php endif ?>
		</table>
	</div>	
<!-- ITEM SHOP
		<?php if($itemShop !== false): ?>
		<h3><?=$item->name?> Sold At NPC</h3>
		<?php if(sizeof($itemShop)): ?>
	<div style="overflow-x:auto;">	
		<table class="vertical-table">
			<tr>
				<th>Name</th>
				<th>Map</th>
				<th>Coordinates</th>
				<th>Sell Price</th>
			</tr>
			<?php foreach($itemShop as $it){ ?>
				<tr>
					<?php if($auth->actionAllowed('npcs', 'view')){ ?>
						<td><a href="<?=$this->url('npcs', 'view', array('id' => $it->id))?>"><?=$it->name?></a></td>
					<?php } else { ?>
						<td><?=$it->name?></td>
					<?php } ?>
					<?php if($auth->actionAllowed('map', 'view')){ ?>
						<td><a href="<?=$this->url('map', 'view', array('map' => $it->map))?>"><?=$it->map?></a></td>
					<?php } else { ?>
						<td><?=$it->map?></td>
					<?php } ?>
					<td><?=$it->x?>,<?=$it->y?></td>
					<td><?=$it->price?></td>
				</tr>
			<?php } ?>
					</table>
	</div>				
				<?php else: ?>
					This item can not be bought
				<?php endif ?>
			<?php endif ?>
			

 ITEM SHOP -->
		<?php else: ?>
		<p>No such item was found. <a href="javascript:history.go(-1)">Go back</a>.</p>
		<?php endif ?>	


