<link href="css/menu.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/plugins/menu/iutil.js"></script>
<script type="text/javascript" src="js/plugins/menu/idrag.js"></script>
<script type="text/javascript" src="js/plugins/menu/idrop.js"></script>
<script type="text/javascript" src="js/plugins/menu/isortables.js"></script>
<script type="text/javascript" src="js/plugins/menu/inestedsortable.js"></script>
<script type="text/javascript" src="js/plugins/menu/menu.js"></script>
<script>
	var current_group_id = <?php echo $group_id; ?>;
</script>
<?php
session_start();
if (empty($_SESSION['namauser']) AND empty($_SESSION['passuser'])){
	header('location:404.php');
}else{
?>
	<div class="contentTop">
        <span class="pageTitle"><span class="icos-view"></span>Menu Manager</span>
    </div>
    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
                <li><a href="admin.php?mod=home"><?php echo $langmenu1; ?></a></li>
                <li class="current"><a>Input, edit, view and delete menu management</a></li>
            </ul>
        </div>
    </div>
    <!-- Main content -->
    <div class="wrapper">
		<div class="widget">
			<div class="whead">&nbsp;<div class="clear"></div></div>
			<section>
				<article>
					<section>
						<ul id="menu-group">
							<?php foreach ((array)$menu_groups as $id => $title) : ?>
							<li id="group-<?php echo $id; ?>">
								<a href="<?php echo site_url('menu&amp;group_id=' . $id); ?>">
									<?php echo $title; ?>
								</a>
							</li>
							<?php endforeach; ?>
							<li id="add-group"><a href="#" title="Add Menu Group">+</a></li>
						</ul>
						<div class="clear"></div>

						<form method="post" id="form-menu" action="po-component/po-menumanager/proses.php?mod=menu&act=save_position">
							<div class="ns-row" id="ns-header">
								<div class="ns-actions">Actions</div>
								<div class="ns-class">Class</div>
								<div class="ns-url">URL</div>
								<div class="ns-title">Title</div>
							</div>
							<?php echo $menu_ul; ?>
							<div id="ns-footer">
								<button type="submit" class="buttonM bBlue" id="btn-save-menu">Update Menu</button>
							</div>
						</form>
					</section>
					<aside>
						<div class="box info">
							<h2>Info</h2>
							<section>
								<p>Drag the menu list to re-order, and click <b>Update Menu</b> to save the position.</p>
								<p>To add a menu, use the <b>Add Menu</b> form below.</p>
							</section>
						</div>
						<div class="box">
							<h2>Current Menu Group</h2>
							<section>
								<span id="edit-group-input"><?php echo $group_title; ?></span>
								(ID: <b><?php echo $group_id; ?></b>)
								<div style="margin-top:5px;">
									<a id="edit-group" class="buttonM bBlue" href="#">Edit</a>
									<?php if ($group_id > 1) : ?>
									&middot; <a id="delete-group" class="buttonM bRed" href="#">Delete</a>
									<?php endif; ?>
								</div>
							</section>
						</div>
						<div class="box">
							<h2>Add Menu</h2>
							<section>
								<form id="form-add-menu" method="post" action="po-component/po-menumanager/proses.php?mod=menu&act=add">
									<p>
										<label for="menu-title">Title</label>
										<input type="text" name="title" id="menu-title">
									</p>
									<p>
										<label for="menu-url">URL</label>
										<input type="text" name="url" id="menu-url">
									</p>
									<p>
										<label for="menu-class">Class</label>
										<input type="text" name="class" id="menu-class">
									</p>
									<p class="buttons">
										<input type="hidden" name="group_id" value="<?php echo $group_id; ?>">
										<button id="add-menu" type="submit" class="buttonM bBlue">Add Menu</button>
									</p>
								</form>
							</section>
						</div>
					</aside>
					<div class="clear"></div>
				</article>
			</section>
		</div>
	</div>
	<div id="loading">
		<img src="images/menu/ajax-loader.gif" alt="Loading">
		Processing...
	</div>
<?php } ?>