<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Revised: 2/8/2012	ELL
// Added table prefix handling. Added references to CSS and scripts folder configurations.
//
	include ("check_session.php");
	
	$suffix = $_REQUEST['suffix'];
	$menu_type = $_REQUEST['menu_type'];
	
	if (BWB_BASE_DIR == '')
		$website_path = '';
	else
		$website_path = "/" . BWB_BASE_DIR;
		
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Breeze Website Builder Menu Styles Preview</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="..<?php echo $website_path . "/" . BWB_CSS_DIR; ?>/site.css" type="text/css">
<link rel="stylesheet" href="..<?php echo $website_path . "/" . BWB_CSS_DIR; ?>/menu_preview.css" type="text/css">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">

<script language="JavaScript" src="..<?php echo $website_path . "/" . BWB_SCRIPTS_DIR; ?>/menu.js"></script>

<script language="JavaScript" src="..<?php echo $website_path . "/" . BWB_SCRIPTS_DIR; ?>/menu_items_preview.js"></script>

<script language="JavaScript" src="..<?php echo $website_path . "/" . BWB_SCRIPTS_DIR . "/menu" . $suffix; ?>_tpl.js"></script>
</head>

<body>
<script language="JavaScript">
<?php
	if ($menu_type == 1)
      echo "new menu (MENU_ITEMS, MENU" . $suffix . "_POS);";
?>
</script>
<?php
	$menu_name = "menu" . $suffix;
	$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "menu_assignments WHERE menu_name = '" . $menu_name . "'";
	$result = $bwb_dbh->query($query);
	$row = $result->fetch(PDO::FETCH_ASSOC);
	$border_area = $row["border_area"];
	echo "<table><tr><td id='" . $border_area . "_td' class='" . $border_area . "_td'><div id='" . $border_area . "_div' class='" . $border_area . "_div'>\n";
	$menu_generator_path = ".." . $website_path . "/" . BWB_SCRIPTS_DIR . "/menu_gen.php";
	include ($menu_generator_path);
	echo "</div></td></tr></table>\n";
?>
<form action="save_menu_css_from_preview.php" method="post" name="frmSaveMenuCSS">
<table width="80">
  <tr>
	  <td align="center">
	  <input type="hidden" name="menu" value="<?php echo $menu_name; ?>" />
      <input type="hidden" name="menu_type" value="<?php echo $menu_type; ?>" />
      <input type="submit" value="Save Changes" name="submit" />
	  </td>
      
	  <td align="center">
       <input type="button" name="Back" value="Exit Without Saving"
       onClick="window.location.href='edit_<?php if ($menu_type == 1) echo "js"; else echo "css"; ?>_menu_styles.php?menu=<?php echo $menu_name; ?>';" />
	  </td>
  </tr>
</table>
</form>
</body>
</html>
