<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright EB Dynamics, Inc., Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 11/11/2009	ELL
// Revised: 11/11/2009	ELL
// Added menu item classes and styles for individual item control.
// Revised: 1/8/2011	ELL
// Added code to remove JavaScript from HTML record if necessary.
// Revised: 2/8/2012	ELL
// Added table prefix handling.
// 
	include ("check_session.php");
	
	$menu = $_GET['menu'];
	
	if (($menu != "menu") && ($menu != "menu1"))
	{
		$suffix = substr($menu, 4);
		
		/////// Look for JavaScript Menu and remove code if necessary. ///////////////
		$query = "SELECT * FROM `" . BWB_TABLE_PREFIX . "menus` WHERE `menu_name` = '$menu'";
		$result = mysql_query($query, $bwb_link);
		$row = mysql_fetch_array($result);
		$menu_type = $row["menu_type"];
		if ($menu_type == 1)
		{
			$query = "SELECT * FROM `" . BWB_TABLE_PREFIX . "menu_assignments` WHERE `menu_name` = '$menu'";
			$result = mysql_query($query, $bwb_link);
			$row = mysql_fetch_array($result);
			$border_area = $row["border_area"];
			include("remove_menu_code.php");
		}
		//////////////////////////////////////////////////////////////////////////////
		
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "menu_assignments` WHERE `menu_name` = $menu";
		$result = mysql_query($query, $bwb_link);
		
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "menus` WHERE `menu_name` = '$menu'";
		$result = mysql_query($query, $bwb_link);
		
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "style_sheets` WHERE `name` = '$menu'";
		$result = mysql_query($query, $bwb_link);
		
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "style_sheets` WHERE `name` = '" . $menu . "_item'";
		$result = mysql_query($query, $bwb_link);
			
		$query = "DROP TABLE IF EXISTS " . BWB_TABLE_PREFIX . "menu"  . $suffix . "_classes";
		$result = mysql_query($query, $bwb_link);
		
		$query = "DROP TABLE IF EXISTS " . BWB_TABLE_PREFIX . "menu" . $suffix . "_css";
		$result = mysql_query($query, $bwb_link);
		
		$query = "DROP TABLE IF EXISTS " . BWB_TABLE_PREFIX . "menu" . $suffix . "_items";
		$result = mysql_query($query, $bwb_link);
		
		$query = "DROP TABLE IF EXISTS " . BWB_TABLE_PREFIX . "menu"  . $suffix . "_item_classes";
		$result = mysql_query($query, $bwb_link);
		
		$query = "DROP TABLE IF EXISTS " . BWB_TABLE_PREFIX . "menu" . $suffix . "_item_css";
		$result = mysql_query($query, $bwb_link);
	}
	
	header("Location: manage_menu.php");
	
?>
