<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created:	10/22/2016	ELL
// 
// 

	include ("check_session.php");

	$last_border_edited = $_SESSION['last_border_edited'];
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Manage Mega Menus | Breeze Website Builder</title>
<link rel="stylesheet" href="theme/<?php echo $theme; ?>/manager.css" type="text/css">

<style>
#editor_options_div	{
<?php if (($access_level == "admin") || ($access_level == "power_user"))	{	?>
	display:block;
	position:absolute;
	top:50px;
	left:400px;
<?php	} else	echo "	display:none;\n";	?>
}

#create_mega_menu_div	{
	position:absolute;
	top:170px;
	right:15%;
}

#create_btn	{
	width:150px;
}
</style>

<script src="js/ajax.js"> </script>
<script src="js/json2.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/browser_detect.js"></script>
<script src="js/mouse_position.js"></script>
<script src="js/popup_msg.js"></script>
<script src="js/manage_mega_menu.js"></script>

<script>
<?php
	echo "	var MEGA_MENU_PAGE_ALREADY_EXISTS_1_ERR = \"" . MEGA_MENU_PAGE_ALREADY_EXISTS_1_ERR . "\";\n";
	echo "	var MEGA_MENU_PAGE_ALREADY_EXISTS_2_ERR = \"" . MEGA_MENU_PAGE_ALREADY_EXISTS_2_ERR . "\";\n";
	
	echo "	var http = '$http';\n";
?>
</script>
</head>

<body>
	<div class='button_console_go_back' style="width:220px; position:absolute; right:20px; top:0px;" onClick="window.location.href='edit_menu_items.php'"><span class='button_console_text_w_icon'><?php echo MEGA_MENU_BACK_BTN; ?></span></div>

 <div id="sub_level_1_buttons">
	 	
            <div class="button_heading_sub_level_1"><div class="button_heading_text_sub_level_1"><?php echo MEGA_MENU_EDIT_SELECT_HEADING; ?></div><div class="button_heading_help" onClick="OpenHelpWindow();">&nbsp;</div></div>
		<?php
			$query = "SELECT page_name FROM " . BWB_TABLE_PREFIX . "page_data_special WHERE page_name LIKE 'mm_%' ORDER BY page_name";
			$result = $bwb_dbh->query($query);
			$num_results = $result->rowCount();
			for ($i = 0; $i < $num_results; $i++)
			{
				$row = $result->fetch(PDO::FETCH_ASSOC);
				$page_name = $row["page_name"];
					
				if ($page_name == $last_border_edited)
					$selected = " down_sub";
				else
					$selected = "";
					
				echo "<div class='button_sub_level_1$selected' onClick=\"window.location='edit_page.php?page_name=$page_name&mode=mega_menu&special=1&source=manage_mega_menu.php';\"><span class='button_text_sub_level_1'>$page_name</span></div>\n";
			}
		?>
</div>
     
     <div id="editor_options_div">
    <span class="bold"><?php echo EDIT_PAGE_SELECT_OPTIONS_HEADING; ?></span><br /><br />
    <input type="checkbox" id="editor_mode" name="editor_mode" onChange="SetEditorMode('editor_mode');" <?php if (isset($_SESSION['editor_mode']) && ($_SESSION['editor_mode'] == 1)) echo "checked='checked'"; ?> />
    <?php echo EDIT_PAGE_SELECT_SOURCE_VIEW_OPTION; ?><br /><br />
    <?php echo EDIT_PAGE_SELECT_DEVICE_EMULATION; ?>:<br />
    <input type="radio" id="style_mode[0]" name="style_mode" value="desktop" onChange="SetEditorMode('style_mode[0]');" <?php if (!isset($_SESSION['style_mode']) || ($_SESSION['style_mode'] == "desktop")) echo "checked='checked'"; ?> />
    <?php echo DESKTOP_WORD; ?><br />
    <input type="radio" id="style_mode[1]" name="style_mode" value="mobile" onChange="SetEditorMode('style_mode[1]');" <?php if (isset($_SESSION['style_mode']) && ($_SESSION['style_mode'] == "mobile")) echo "checked='checked'"; ?> />
    <?php echo MOBILE_WORD; ?><br />
    <input type="radio" id="style_mode[2]" name="style_mode" value="touchscreen" onChange="SetEditorMode('style_mode[2]');" <?php if (isset($_SESSION['style_mode']) && ($_SESSION['style_mode'] == "touchscreen")) echo "checked='checked'"; ?> />
    <?php echo TOUCHSCREEN_WORD; ?><br /><br />
    </div>
    
    <div id="create_mega_menu_div">
    <div class="button_heading_sub_level_1"><div class="button_heading_text_sub_level_1"><?php echo MEGA_MENU_CREATE_HEADING; ?></div><div class="button_heading_help" onClick="OpenHelpWindow();">&nbsp;</div></div>
     
     <br />
     <table style="border:none;">
     <tr><td class="sub_title"><?php echo MENU_WORD; ?>:</td><td class="sub_title"><?php echo MENU_ITEM; ?>:</td></tr>
     <tr><td>
     <select name="menu" id="menu" onChange="PopulateMenuItems(this.value);">
     <option value=""><?php echo _NOT_SELECTED_; ?></option>
<?php
	$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "menus";
	$result = $bwb_dbh->query($query);
	while($row = $result->fetch(PDO::FETCH_ASSOC))
	{
		$menu_name = $row['menu_name'];
		$description = $row['description'];
		echo "	<option value='$menu_name'>$description</option>\n";
	}
?>
     </select>
     </td><td>
     <select name="menu_item" id="menu_item" onChange="CheckRequirements();">
     <option value=""><?php echo _NOT_SELECTED_; ?></option>
     </select>
     </td></tr>
     <tr><td colspan="2" style="text-align:right;" align="right">
     <br /><br />
     <div style="text-align:right; width:100%; padding-left:100px;">
     <div class='button_console_add_disabled' onClick="CreateMegaMenu();" id="create_btn"><span class='button_console_text_w_icon'><?php echo CREATE_WORD; ?></span></div>
     </div>
     </td></tr>
     </table>
     </div>
     
     <?php include("lib/popup_msg.html"); ?>
     
<script language='javascript' type='text/javascript'>
	popup_msg.HidePopupMsg();
</script>
</body>
</html>