<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 10/23/2009		ELL
// Revised: 11/11/2009	ELL
// Added options for proportional item widths.
// Modified: 1/6/2010		ELL
// Added z-indexing to fix bug of sublevels not popping above main level upon hover.
// Modified: 10/7/2010		ELL
// Added text align.
// Modified: 2/4/2012	ELL
// Added selection for having sub menus collapse and expand.  Default is to collapse and expand.  New option is to show always expanded.
// Revised: 2/10/2012	ELL
// Added table prefix handling.  Added references to CSS folder configurations.
// Revised: 6/19/2013	ELL
// Added separate text alignment for sub menus.
// Revised: 7/21/2013	ELL
// Fixed bug with opacity being left at 0 if menu freshly cerated.
// Revised: 12/16/2013	ELL
// Added ability to specify bottom and right offsets as well as manually editing positioning.
// Revised: 1/15/2015	ELL
// Added full complement of units to all pertinent attributes.
// Revised: 3/28/2016	ELL
// Fixed bug with horizontal fixed width not saving width.
// Fixed bug with menu top and left not saving with insert new record.
// Modified: 12/2/2016	ELL
// Consolidated all class tables into site_classes table indexed by style_sheet field.
// Consolidated all CSS tables into site_css table indexed by style_sheet field.
// Modified: 3/27/2017	ELL
// Modified location of some styles per class for CSS menu system overhaul.
// Revised: 5/18/2017	ELL
// Modified to save top-level menu item width as min width of menu for vertical menus.
// Revised fixed-width horizontal menus to restore ability to span items across specified width.  (Required addition of flex.)
// Modified: 8/21/2017	ELL
// Added Ability to latch sub items as expanded when top or any sub is down.
// Modified: 9/18/2017	ELL
// Added user modifiable menu z-index.
// Revised: 1/2/2018	ELL
// Fixed bug where text align selection would not effect menu items with no link.
// Revised: 6/29/2018	ELL
// Fixed bug of sub menu disappearing when there is a gap between parent level and sub level and mouse goes in between last parent item and first child item.
// Fixed bug of sub menu disappearing when there is a gap between sub menus items and when mouse goes between sub menu items.
// Revised: 10/12/2018	ELL
// Changed CSS field from "align" to "text_align" to match actual CSS term.
// Added all transition attributes.
// 
//
//
	include ("check_session.php");
	include("lib/build_css_string.php");
		
	$menu = $_REQUEST['menu'];
	$search = array("_mobile", "_touchscreen");
	$tmp = str_replace($search, "", $menu);
	$suffix = substr($tmp, 4);
	$css_file = $menu . ".css";

	if (isset($_POST["OrientationGroup"])) $orientation = $_POST["OrientationGroup"];
	else $orientation = "horizontal_fixed_width";
	if (isset($_POST["PositionGroup"])) $position = $_POST["PositionGroup"];
	else $position = "absolute";
	if (is_numeric($_POST["menu_top"])) $menu_top = $_POST["menu_top"];
	else $menu_top = -1000000;
	if (is_numeric($_POST["menu_left"])) $menu_left = $_POST["menu_left"];
	else $menu_left = -1000000;
	if (is_numeric($_POST["menu_bottom"])) $menu_bottom = $_POST["menu_bottom"];
	else $menu_bottom = -1000000;
	if (is_numeric($_POST["menu_right"])) $menu_right = $_POST["menu_right"];
	else $menu_right = -1000000;
	
	if (isset($_POST["Sub1OrientationGroup"])) $sub_level_1_orientation = $_POST["Sub1OrientationGroup"];
	else $sub_level_1_orientation = "vertical";
	if (isset($_POST["Sub2OrientationGroup"])) $sub_level_2_orientation = $_POST["Sub2OrientationGroup"];
	else $sub_level_2_orientation = "vertical";
	
	if (is_numeric($_POST["menu_top_units"])) $menu_top_units = $_POST["menu_top_units"];
	else $menu_top_units = 0;
	if (is_numeric($_POST["menu_left_units"])) $menu_left_units = $_POST["menu_left_units"];
	else $menu_left_units = 0;
	if (is_numeric($_POST["menu_bottom_units"])) $menu_bottom_units = $_POST["menu_bottom_units"];
	else $menu_bottom_units = 0;
	if (is_numeric($_POST["menu_right_units"])) $menu_right_units = $_POST["menu_right_units"];
	else $menu_right_units = 0;
	
	if (is_numeric($_POST["menu_width"])) $menu_width = $_POST["menu_width"];
	else $menu_width = -1;
	if (is_numeric($_POST["menu_width_units"])) $menu_width_units = $_POST["menu_width_units"];
	else $menu_width_units = 1;
	if (is_numeric($_POST["top_level_item_width"])) $top_level_item_width = $_POST["top_level_item_width"];
	else $top_level_item_width = -1;
	if (is_numeric($_POST["top_level_item_width_units"])) $top_level_item_width_units = $_POST["top_level_item_width_units"];
	else $top_level_item_width_units = 0;
	if (is_numeric($_POST["top_level_item_height"])) $top_level_item_height = $_POST["top_level_item_height"];
	else $top_level_item_height = -1;
	if (is_numeric($_POST["top_level_item_height_units"])) $top_level_item_height_units = $_POST["top_level_item_height_units"];
	else $top_level_item_height_units = 0;
	if (isset($_POST["top_level_text_align"])) $top_level_text_align = $_POST["top_level_text_align"];
	else $top_level_text_align = "-not selected-";
	if (is_numeric($_POST["top_level_padding_top"])) $top_level_padding_top = $_POST["top_level_padding_top"];
	else $top_level_padding_top = -1;
	if (is_numeric($_POST["top_level_padding_right"])) $top_level_padding_right = $_POST["top_level_padding_right"];
	else $top_level_padding_right = -1;
	if (is_numeric($_POST["top_level_padding_bottom"])) $top_level_padding_bottom = $_POST["top_level_padding_bottom"];
	else $top_level_padding_bottom = -1;
	if (is_numeric($_POST["top_level_padding_left"])) $top_level_padding_left = $_POST["top_level_padding_left"];
	else $top_level_padding_left = -1;
	
	if (is_numeric($_POST["top_level_padding_top_units"])) $top_level_padding_top_units = $_POST["top_level_padding_top_units"];
	else $top_level_padding_top_units = 0;
	if (is_numeric($_POST["top_level_padding_right_units"])) $top_level_padding_right_units = $_POST["top_level_padding_right_units"];
	else $top_level_padding_right_units = 0;
	if (is_numeric($_POST["top_level_padding_bottom_units"])) $top_level_padding_bottom_units = $_POST["top_level_padding_bottom_units"];
	else $top_level_padding_bottom_units = 0;
	if (is_numeric($_POST["top_level_padding_left_units"])) $top_level_padding_left_units = $_POST["top_level_padding_left_units"];
	else $top_level_padding_left_units = 0;
	
	if (is_numeric($_POST["sub_level_1_offset_top"])) $sub_level_1_offset_top = $_POST["sub_level_1_offset_top"];
	else $sub_level_1_offset_top = -1000000;
	if (is_numeric($_POST["sub_level_1_offset_top_units"])) $sub_level_1_offset_top_units = $_POST["sub_level_1_offset_top_units"];
	else $sub_level_1_offset_top_units = 0;
	if (is_numeric($_POST["sub_level_1_offset_left"])) $sub_level_1_offset_left = $_POST["sub_level_1_offset_left"];
	else $sub_level_1_offset_left = -1000000;
	if (is_numeric($_POST["sub_level_1_offset_left_units"])) $sub_level_1_offset_left_units = $_POST["sub_level_1_offset_left_units"];
	else $sub_level_1_offset_left_units = 0;
	if (is_numeric($_POST["sub_level_1_item_width"])) $sub_level_1_item_width = $_POST["sub_level_1_item_width"];
	else $sub_level_1_item_width = -1;
	if (is_numeric($_POST["sub_level_1_item_width_units"])) $sub_level_1_item_width_units = $_POST["sub_level_1_item_width_units"];
	else $sub_level_1_item_width_units = 0;
	if (is_numeric($_POST["sub_level_1_item_height"])) $sub_level_1_item_height = $_POST["sub_level_1_item_height"];
	else $sub_level_1_item_height = -1;
	if (is_numeric($_POST["sub_level_1_item_height_units"])) $sub_level_1_item_height_units = $_POST["sub_level_1_item_height_units"];
	else $sub_level_1_item_height_units = 0;
	if (is_numeric($_POST["sub_level_1_padding_top"])) $sub_level_1_padding_top = $_POST["sub_level_1_padding_top"];
	else $sub_level_1_padding_top = -1;
	if (is_numeric($_POST["sub_level_1_padding_right"])) $sub_level_1_padding_right = $_POST["sub_level_1_padding_right"];
	else $sub_level_1_padding_right = -1;
	if (is_numeric($_POST["sub_level_1_padding_bottom"])) $sub_level_1_padding_bottom = $_POST["sub_level_1_padding_bottom"];
	else $sub_level_1_padding_bottom = -1;
	if (is_numeric($_POST["sub_level_1_padding_left"])) $sub_level_1_padding_left = $_POST["sub_level_1_padding_left"];
	else $sub_level_1_padding_left = -1;
	
	if (is_numeric($_POST["sub_level_1_padding_top_units"])) $sub_level_1_padding_top_units = $_POST["sub_level_1_padding_top_units"];
	else $sub_level_1_padding_top_units = 0;
	if (is_numeric($_POST["sub_level_1_padding_right_units"])) $sub_level_1_padding_right_units = $_POST["sub_level_1_padding_right_units"];
	else $sub_level_1_padding_right_units = 0;
	if (is_numeric($_POST["sub_level_1_padding_bottom_units"])) $sub_level_1_padding_bottom_units = $_POST["sub_level_1_padding_bottom_units"];
	else $sub_level_1_padding_bottom_units = 0;
	if (is_numeric($_POST["sub_level_1_padding_left_units"])) $sub_level_1_padding_left_units = $_POST["sub_level_1_padding_left_units"];
	else $sub_level_1_padding_left_units = 0;
	
	if (is_numeric($_POST["sub_level_2_offset_top"])) $sub_level_2_offset_top = $_POST["sub_level_2_offset_top"];
	else $sub_level_2_offset_top = -1000000;
	if (is_numeric($_POST["sub_level_2_offset_top_units"])) $sub_level_2_offset_top_units = $_POST["sub_level_2_offset_top_units"];
	else $sub_level_2_offset_top_units = 0;
	if (is_numeric($_POST["sub_level_2_offset_left"])) $sub_level_2_offset_left = $_POST["sub_level_2_offset_left"];
	else $sub_level_2_offset_left = -1000000;
	if (is_numeric($_POST["sub_level_2_offset_left_units"])) $sub_level_2_offset_left_units = $_POST["sub_level_2_offset_left_units"];
	else $sub_level_2_offset_left_units = 0;
	if (is_numeric($_POST["sub_level_2_item_width"])) $sub_level_2_item_width = $_POST["sub_level_2_item_width"];
	else $sub_level_2_item_width = -1;
	if (is_numeric($_POST["sub_level_2_item_width_units"])) $sub_level_2_item_width_units = $_POST["sub_level_2_item_width_units"];
	else $sub_level_2_item_width_units = 0;
	if (is_numeric($_POST["sub_level_2_item_height"])) $sub_level_2_item_height = $_POST["sub_level_2_item_height"];
	else $sub_level_2_item_height = -1;
	if (is_numeric($_POST["sub_level_2_item_height_units"])) $sub_level_2_item_height_units = $_POST["sub_level_2_item_height_units"];
	else $sub_level_2_item_height_units = 0;
	if (is_numeric($_POST["sub_level_2_padding_top"])) $sub_level_2_padding_top = $_POST["sub_level_2_padding_top"];
	else $sub_level_2_padding_top = -1;
	if (is_numeric($_POST["sub_level_2_padding_right"])) $sub_level_2_padding_right = $_POST["sub_level_2_padding_right"];
	else $sub_level_2_padding_right = -1;
	if (is_numeric($_POST["sub_level_2_padding_bottom"])) $sub_level_2_padding_bottom = $_POST["sub_level_2_padding_bottom"];
	else $sub_level_2_padding_bottom = -1;
	if (is_numeric($_POST["sub_level_2_padding_left"])) $sub_level_2_padding_left = $_POST["sub_level_2_padding_left"];
	else $sub_level_2_padding_left = -1;
	
	if (is_numeric($_POST["sub_level_2_padding_top_units"])) $sub_level_2_padding_top_units = $_POST["sub_level_2_padding_top_units"];
	else $sub_level_2_padding_top_units = 0;
	if (is_numeric($_POST["sub_level_2_padding_right_units"])) $sub_level_2_padding_right_units = $_POST["sub_level_2_padding_right_units"];
	else $sub_level_2_padding_right_units = 0;
	if (is_numeric($_POST["sub_level_2_padding_bottom_units"])) $sub_level_2_padding_bottom_units = $_POST["sub_level_2_padding_bottom_units"];
	else $sub_level_2_padding_bottom_units = 0;
	if (is_numeric($_POST["sub_level_2_padding_left_units"])) $sub_level_2_padding_left_units = $_POST["sub_level_2_padding_left_units"];
	else $sub_level_2_padding_left_units = 0;
	
	if (isset($_POST["sub_level_1_text_align"])) $sub_level_1_text_align = $_POST["sub_level_1_text_align"];
	else $sub_level_1_text_align = "-not selected-";
	if (isset($_POST["sub_level_2_text_align"])) $sub_level_2_text_align = $_POST["sub_level_2_text_align"];
	else $sub_level_2_text_align = "-not selected-";
	if (isset($_POST["proportional_width_top"])) $proportional_width_top = $_POST["proportional_width_top"];
	else $proportional_width_top = 0;
	if (isset($_POST["proportional_width_sub"])) $proportional_width_sub = $_POST["proportional_width_sub"];
	else $proportional_width_sub = 0;
	if (isset($_POST["sub_level_collapse"])) $sub_level_collapse = true;
	else $sub_level_collapse = false;
	if (isset($_POST["top_down_on_sub_down"])) $top_down_on_sub_down = $_POST["top_down_on_sub_down"];
	else $top_down_on_sub_down = 0;
	
	if (is_numeric($_POST["top_level_item_spacing"])) $top_level_item_spacing = $_POST["top_level_item_spacing"];
	else $top_level_item_spacing = -1000000;
	if (is_numeric($_POST["top_level_item_spacing_units"])) $top_level_item_spacing_units = $_POST["top_level_item_spacing_units"];
	else $top_level_item_spacing_units = 0;
	if (is_numeric($_POST["sub_level_1_item_spacing"])) $sub_level_1_item_spacing = $_POST["sub_level_1_item_spacing"];
	else $sub_level_1_item_spacing = -1000000;
	if (is_numeric($_POST["sub_level_1_item_spacing_units"])) $sub_level_1_item_spacing_units = $_POST["sub_level_1_item_spacing_units"];
	else $sub_level_1_item_spacing_units = 0;
	if (is_numeric($_POST["sub_level_2_item_spacing"])) $sub_level_2_item_spacing = $_POST["sub_level_2_item_spacing"];
	else $sub_level_2_item_spacing = -1000000;
	if (is_numeric($_POST["sub_level_2_item_spacing_units"])) $sub_level_2_item_spacing_units = $_POST["sub_level_2_item_spacing_units"];
	else $sub_level_2_item_spacing_units = 0;
	
	if (is_numeric($_POST["menu_z_index"])) $menu_z_index = $_POST["menu_z_index"];
	else $menu_z_index = -1000000;
	
	if (isset($_POST["sub_level_1_transition_timing_function"])) $sub_level_1_transition_timing_function = $_POST["sub_level_1_transition_timing_function"];
	else $sub_level_1_transition_timing_function = "-not selected-";
	if (is_numeric($_POST["sub_level_1_transition_duration"])) $sub_level_1_transition_duration = $_POST["sub_level_1_transition_duration"];
	else $sub_level_1_transition_duration = -1;
	if (is_numeric($_POST["sub_level_1_transition_duration_units"])) $sub_level_1_transition_duration_units = $_POST["sub_level_1_transition_duration_units"];
	else $sub_level_1_transition_duration_units = 0;
	if (is_numeric($_POST["sub_level_1_transition_delay"])) $sub_level_1_transition_delay = $_POST["sub_level_1_transition_delay"];
	else $sub_level_1_transition_delay = -1;
	if (is_numeric($_POST["sub_level_1_transition_delay_units"])) $sub_level_1_transition_delay_units = $_POST["sub_level_1_transition_delay_units"];
	else $sub_level_1_transition_delay_units = 0;
	
	if (($sub_level_1_transition_timing_function != "-not selected-") || ($sub_level_1_transition_duration > -1) || ($sub_level_1_transition_delay > -1))
		$sub_level_1_transitions = true;
	else
		$sub_level_1_transitions = false;
	
	if (isset($_POST["sub_level_2_transition_timing_function"])) $sub_level_2_transition_timing_function = $_POST["sub_level_2_transition_timing_function"];
	else $sub_level_2_transition_timing_function = "-not selected-";
	if (is_numeric($_POST["sub_level_2_transition_duration"])) $sub_level_2_transition_duration = $_POST["sub_level_2_transition_duration"];
	else $sub_level_2_transition_duration = -1;
	if (is_numeric($_POST["sub_level_2_transition_duration_units"])) $sub_level_2_transition_duration_units = $_POST["sub_level_2_transition_duration_units"];
	else $sub_level_2_transition_duration_units = 0;
	if (is_numeric($_POST["sub_level_2_transition_delay"])) $sub_level_2_transition_delay = $_POST["sub_level_2_transition_delay"];
	else $sub_level_2_transition_delay = -1;
	if (is_numeric($_POST["sub_level_2_transition_delay_units"])) $sub_level_2_transition_delay_units = $_POST["sub_level_2_transition_delay_units"];
	else $sub_level_2_transition_delay_units = 0;
	
	if (($sub_level_2_transition_timing_function != "-not selected-") || ($sub_level_2_transition_duration > -1) || ($sub_level_2_transition_delay > -1))
		$sub_level_2_transitions = true;
	else
		$sub_level_2_transitions = false;
		
	// Needed if transitions are in use.
	$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_ul" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)	{
		$row = $result->fetch(PDO::FETCH_ASSOC);
		$sub_level_1_block_border_width = $row['border'];
		$sub_level_1_block_border_sides = $row['border_sides'];
		$sub_level_1_block_border_style = $row['border_style'];
		$sub_level_1_block_border_color = $row['border_color'];
	}
	else	{
		$sub_level_1_block_border_width = -1;
	}
	
	$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_ul" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)	{
		$row = $result->fetch(PDO::FETCH_ASSOC);
		$sub_level_2_block_border_width = $row['border'];
		$sub_level_2_block_border_sides = $row['border_sides'];
		$sub_level_2_block_border_style = $row['border_style'];
		$sub_level_2_block_border_color = $row['border_color'];
	}
	else	{
		$sub_level_2_block_border_width = -1;
	}

	///////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = 'ul.nav" . $suffix . ", .nav" . $suffix . " ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
			
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, padding_top=0, padding_right=0, padding_bottom=0,"
		. " padding_left=0, margin_top=0, margin_right=0, margin_left=0, margin_bottom=0, display='-not selected-',"
		. " list_style_type='none' WHERE style_sheet = '" . $menu . "' AND class='ul.nav" . $suffix . ", .nav" . $suffix . " ul'";
	}
	else
	{
		//Insert new data into table.	Note: border set to -2 to indicate first time setup.  This triggers loading of default styles.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='ul.nav" . $suffix . ", .nav" . $suffix . " ul', use_table_data=1, padding_top=0,"
		. " padding_right=0, padding_bottom=0, padding_left=0, margin_top=0, margin_right=0, margin_left=0, margin_bottom=0, display='-not selected-',"
		. " list_style_type='none', border=-2";
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = 'ul.nav" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($orientation == "horizontal_fixed_width")
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='-not selected-', width=". $menu_width . ", width_units="
			. $menu_width_units . ", width_prefix='-not selected-', table_layout='-not selected-' WHERE style_sheet = '" . $menu . "' AND class='ul.nav" . $suffix . "'";
		elseif ($orientation == "horizontal_variable_width")
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='table', width=-1, table_layout='-not selected-'"
			. " WHERE style_sheet = '" . $menu . "' AND class='ul.nav" . $suffix . "'";
		else
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='table', width=" . $top_level_item_width 
			. ", width_units=" . $top_level_item_width_units . ", width_prefix='min', table_layout='-not selected-'"
			. " WHERE style_sheet = '" . $menu . "' AND class='ul.nav" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		if ($orientation == "horizontal_fixed_width")
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='ul.nav" . $suffix . "', use_table_data=1, display='-not selected-', width=" 
			. $menu_width . ", width_units=" . $menu_width_units . ", width_prefix='-not selected-', table_layout='-not selected-'";
		elseif ($orientation == "horizontal_variable_width")
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='ul.nav" . $suffix . "', use_table_data=1, display='table', width=-1, table_layout='-not selected-'";
		else
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='ul.nav" . $suffix 
			. "', use_table_data=1, display='table', width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units 
			. ", width_prefix='min', table_layout='-not selected-'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.top_level_ul" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		if ($orientation == "horizontal_fixed_width")
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='flex', table_layout='-not selected-', justify_content='space-between', list_style_type='none' WHERE style_sheet = '" . $menu . "' AND class='.top_level_ul" . $suffix . "'";
		else
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=0 WHERE style_sheet = '" . $menu . "' AND class='.top_level_ul" . $suffix . "'";
	}
	else
	{
		if ($orientation == "horizontal_fixed_width")
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, style_sheet = '" . $menu . "', class='.top_level_ul" . $suffix . "', display='flex', table_layout='-not selected-', justify_content='space-between', list_style_type='none'";
		else
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET use_table_data=0, style_sheet = '" . $menu . "', class='.top_level_ul" . $suffix . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = 'ul.nav" . $suffix . ">li'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	$menu_z_index_li = $menu_z_index + 10;

	if ($row_count > 0)
	{	
		//Update class record.
		if ($orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, position='relative', display='-not selected-', `float`='-not selected-'"
			. ", z_index=" . $menu_z_index_li . " WHERE style_sheet = '" . $menu . "' AND class='ul.nav" . $suffix . ">li'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, position='relative', display='block', `float`='left'"
			. ", z_index=" . $menu_z_index_li . " WHERE style_sheet = '" . $menu . "' AND class='ul.nav" . $suffix . ">li'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='ul.nav" . $suffix . ">li', use_table_data=1"
			. ", position='relative', display='-not selected-', `float`='-not selected-', z_index=" . $menu_z_index_li;
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='ul.nav" . $suffix . ">li', use_table_data=1"
			. ", position='relative', display='block', `float`='left', z_index=" . $menu_z_index_li;
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.top_level_a" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $top_level_text_align 
			. "', width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units
			. ", width_prefix='-not selected-', line_height=" . $top_level_item_height . ", line_height_units=" . $top_level_item_height_units
			. ", padding_top=" . $top_level_padding_top	. ", padding_top_units=" . $top_level_padding_top_units 
			. ", padding_right=" . $top_level_padding_right . ", padding_right_units=" . $top_level_padding_right_units
			. ", padding_bottom=" . $top_level_padding_bottom . ", padding_bottom_units=" . $top_level_padding_bottom_units
			. ", padding_left=" . $top_level_padding_left . ", padding_left_units=" . $top_level_padding_left_units
			. " WHERE style_sheet = '" . $menu . "' AND class='.top_level_a" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $top_level_text_align 
			. "', width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units
			. ", width_prefix='min', line_height=" . $top_level_item_height . ", line_height_units=" . $top_level_item_height_units
			. ", padding_top=" . $top_level_padding_top	. ", padding_top_units=" . $top_level_padding_top_units 
			. ", padding_right=" . $top_level_padding_right . ", padding_right_units=" . $top_level_padding_right_units
			. ", padding_bottom=" . $top_level_padding_bottom . ", padding_bottom_units=" . $top_level_padding_bottom_units
			. ", padding_left=" . $top_level_padding_left . ", padding_left_units=" . $top_level_padding_left_units
			. " WHERE style_sheet = '" . $menu . "' AND class='.top_level_a" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_a" . $suffix 
			. "', use_table_data=1, text_align='" . $top_level_text_align . "', width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units
			. ", width_prefix='-not selected-', line_height=" . $top_level_item_height . ", line_height_units=" . $top_level_item_height_units
			. ", padding_top=" . $top_level_padding_top. ", padding_top_units=" . $top_level_padding_top_units
			. ", padding_right=" . $top_level_padding_right . ", padding_right_units=" . $top_level_padding_right_units
			. ", padding_bottom=" . $top_level_padding_bottom . ", padding_bottom_units=" . $top_level_padding_bottom_units
			. ", padding_left=" . $top_level_padding_left . ", padding_left_units=" . $top_level_padding_left_units;
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_a" . $suffix 
			. "', use_table_data=1, text_align='" . $top_level_text_align . "', width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units
			. ", width_prefix='min', line_height=" . $top_level_item_height . ", line_height_units=" . $top_level_item_height_units
			. ", padding_top=" . $top_level_padding_top. ", padding_top_units=" . $top_level_padding_top_units
			. ", padding_right=" . $top_level_padding_right . ", padding_right_units=" . $top_level_padding_right_units
			. ", padding_bottom=" . $top_level_padding_bottom . ", padding_bottom_units=" . $top_level_padding_bottom_units
			. ", padding_left=" . $top_level_padding_left . ", padding_left_units=" . $top_level_padding_left_units;
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.top_level_li" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $top_level_item_spacing . ", margin_bottom_units=" . $top_level_item_spacing_units . ", text_align='" . $top_level_text_align
			. "' WHERE style_sheet = '" . $menu . "' AND class='.top_level_li" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $top_level_item_spacing . ", margin_right_units=" . $top_level_item_spacing_units . ", text_align='" . $top_level_text_align
			. "' WHERE style_sheet = '" . $menu . "' AND class='.top_level_li" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_li" . $suffix 
			. "', use_table_data=1"	. ", margin_bottom=" . $top_level_item_spacing . ", margin_bottom_units=" . $top_level_item_spacing_units . ", text_align='" . $top_level_text_align. "'";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_li" . $suffix 
			. "', use_table_data=1, margin_right=" . $top_level_item_spacing . ", margin_right_units=" . $top_level_item_spacing_units . ", text_align='" . $top_level_text_align . "'";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.top_level_li_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $top_level_item_spacing . ", margin_bottom_units=" . $top_level_item_spacing_units . ", text_align='" . $top_level_text_align
			. "' WHERE style_sheet = '" . $menu . "' AND class='.top_level_li_down" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $top_level_item_spacing . ", margin_right_units=" . $top_level_item_spacing_units . ", text_align='" . $top_level_text_align
			. "' WHERE style_sheet = '" . $menu . "' AND class='.top_level_li_down" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_li_down" . $suffix 
			. "', use_table_data=1"	. ", margin_bottom=" . $top_level_item_spacing . ", margin_bottom_units=" . $top_level_item_spacing_units . ", text_align='" . $top_level_text_align . "'";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_li_down" . $suffix 
			. "', use_table_data=1, margin_right=" . $top_level_item_spacing . ", margin_right_units=" . $top_level_item_spacing_units . ", text_align='" . $top_level_text_align . "'";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.top_level_a_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $top_level_text_align 
			. "', width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units
			. ", width_prefix='-not selected-', line_height=" . $top_level_item_height . ", line_height_units=" . $top_level_item_height_units
			. ", padding_top=" . $top_level_padding_top	. ", padding_top_units=" . $top_level_padding_top_units 
			. ", padding_right=" . $top_level_padding_right . ", padding_right_units=" . $top_level_padding_right_units
			. ", padding_bottom=" . $top_level_padding_bottom . ", padding_bottom_units=" . $top_level_padding_bottom_units
			. ", padding_left=" . $top_level_padding_left . ", padding_left_units=" . $top_level_padding_left_units
			. " WHERE style_sheet = '" . $menu . "' AND class='.top_level_a_down" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $top_level_text_align 
			. "', width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units
			. ", width_prefix='min', line_height=" . $top_level_item_height . ", line_height_units=" . $top_level_item_height_units
			. ", padding_top=" . $top_level_padding_top	. ", padding_top_units=" . $top_level_padding_top_units 
			. ", padding_right=" . $top_level_padding_right . ", padding_right_units=" . $top_level_padding_right_units
			. ", padding_bottom=" . $top_level_padding_bottom . ", padding_bottom_units=" . $top_level_padding_bottom_units
			. ", padding_left=" . $top_level_padding_left . ", padding_left_units=" . $top_level_padding_left_units
			. " WHERE style_sheet = '" . $menu . "' AND class='.top_level_a_down" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_a_down" . $suffix 
			. "', use_table_data=1, text_align='" . $top_level_text_align . "', width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units
			. ", width_prefix='-not selected-', line_height=" . $top_level_item_height . ", line_height_units=" . $top_level_item_height_units
			. ", padding_top=" . $top_level_padding_top. ", padding_top_units=" . $top_level_padding_top_units
			. ", padding_right=" . $top_level_padding_right . ", padding_right_units=" . $top_level_padding_right_units
			. ", padding_bottom=" . $top_level_padding_bottom . ", padding_bottom_units=" . $top_level_padding_bottom_units
			. ", padding_left=" . $top_level_padding_left . ", padding_left_units=" . $top_level_padding_left_units;
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_a_down" . $suffix 
			. "', use_table_data=1, text_align='" . $top_level_text_align . "', width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units
			. ", width_prefix='min', line_height=" . $top_level_item_height . ", line_height_units=" . $top_level_item_height_units
			. ", padding_top=" . $top_level_padding_top. ", padding_top_units=" . $top_level_padding_top_units
			. ", padding_right=" . $top_level_padding_right . ", padding_right_units=" . $top_level_padding_right_units
			. ", padding_bottom=" . $top_level_padding_bottom . ", padding_bottom_units=" . $top_level_padding_bottom_units
			. ", padding_left=" . $top_level_padding_left . ", padding_left_units=" . $top_level_padding_left_units;
		}
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.top_level_li" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	if ($sub_level_1_transitions === true)	{
		$sub_level_1_transition_property = "width, height, min-width, min-height, max-width, max-height, border-width, font-size";
		if (isset($sub_level_1_block_border_width) && ($sub_level_1_block_border_width > 0))
			$border_str = ", border=0, border_units=0";
		else
			$border_str = ", border=-1, border_units=0";
			
		if ($orientation == "vertical")	{
			if ($sub_level_1_orientation == "vertical")
				$height_width_overflow_border_width_str = ", width=0, width_units=14, min_width=0, min_width_units=0, max_width=0, max_width_units=0, height=-1, height_units=0, max_height=-1, max_height_units=0, overflow='hidden'" . $border_str;
			else
				$height_width_overflow_border_width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=0, height_units=14, max_height=0, max_height_units=0, overflow='hidden'" . $border_str;
		}
		else	{
			if ($sub_level_1_orientation == "vertical")
				$height_width_overflow_border_width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=0, height_units=14, max_height=0, max_height_units=0, overflow='hidden'" . $border_str;
			else
				$height_width_overflow_border_width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=0, height_units=14, max_height=0, max_height_units=0, overflow='hidden'" . $border_str;
		}
	}
	else	{
		$sub_level_1_transition_property = "-not selected-";
		$height_width_overflow_border_width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=-1, height_units=0, max_height=-1, max_height_units=0, overflow='-not selected-', border=-1, border_units=0";
	}
		
	if ($sub_level_collapse == true)	{
		if ($sub_level_1_transitions === true)
			$position_display_str = "position='absolute', display='block'";
		else
			$position_display_str = "position='absolute', display='none'";
	}
	elseif ($sub_level_1_transitions === true)
		$position_display_str = "position='-not selected-', display='block'";
	else
		$position_display_str = "position='-not selected-', display='-not selected-'";
	
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, " . $position_display_str . $height_width_overflow_border_width_str
		. ", margin_top=" . $sub_level_1_offset_top . ", margin_top_units=" . $sub_level_1_offset_top_units 
		. ", margin_left=" . $sub_level_1_offset_left . ", margin_left_units=" . $sub_level_1_offset_left_units
		. ", transition_property='" . $sub_level_1_transition_property . "', transition_timing_function='" . $sub_level_1_transition_timing_function
		. "', transition_duration=" . $sub_level_1_transition_duration . ", transition_duration_units=" . $sub_level_1_transition_duration_units
		. ", transition_delay=" . $sub_level_1_transition_delay . ", transition_delay_units=" . $sub_level_1_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.top_level_li" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_li" . $suffix . " > ul', use_table_data=1, "
		. $position_display_str . $height_width_overflow_border_width_str . ", margin_top=" . $sub_level_1_offset_top
		. ", margin_top_units=" . $sub_level_1_offset_top_units 
		. ", margin_left=" . $sub_level_1_offset_left . ", margin_left_units=" . $sub_level_1_offset_left_units
		. ", transition_property='" . $sub_level_1_transition_property . "', transition_timing_function='" . $sub_level_1_transition_timing_function
		. "', transition_duration=" . $sub_level_1_transition_duration . ", transition_duration_units=" . $sub_level_1_transition_duration_units
		. ", transition_delay=" . $sub_level_1_transition_delay . ", transition_delay_units=" . $sub_level_1_transition_delay_units;
	}
//echo $query . "\n";
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = 'ul.nav" . $suffix . " li:hover>ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	$menu_z_index_ul = $menu_z_index + 5;
	
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, z_index=" . $menu_z_index_ul . " WHERE style_sheet = '" . $menu . "' AND class='ul.nav" . $suffix . " li:hover>ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='ul.nav" . $suffix . " li:hover>ul', use_table_data=1, z_index=" . $menu_z_index_ul;
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.nav" . $suffix . " ul li a'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
		. ", display='block' WHERE style_sheet = '" . $menu . "' AND class='.nav" . $suffix . " ul li a'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.nav" . $suffix . " ul li a', use_table_data=1"
		. ", display='block'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.menu_div" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	if (($orientation == "horizontal_fixed_width") && ($menu_width_units == 1))
		$menu_width_str = ", width=". $menu_width . ", width_units=" . $menu_width_units;
	elseif ($orientation == "horizontal_fixed_width")
		$menu_width_str = ", width=-1";
	else
		$menu_width_str = "";

	if ($row_count > 0)
	{	
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, position='" . $position
		. "', position_top=" . $menu_top . ", position_top_units=" . $menu_top_units . ", position_left=" . $menu_left
		. ", position_left_units=" . $menu_left_units . ", position_bottom='" . $menu_bottom . "', position_bottom_units=" . $menu_bottom_units . ", position_right='" 
		. $menu_right . "', position_right_units="  . $menu_right_units . ", display='block', z_index=" . $menu_z_index . $menu_width_str . " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix
		. "', use_table_data=1, position='" . $position . "',"
		. " position_top=" . $menu_top . ", position_top_units=" . $menu_top_units . ", position_left=" . $menu_left
		. ", position_left_units=" . $menu_left_units . ", position_bottom='" . $menu_bottom . "', position_bottom_units=" . $menu_bottom_units . ", position_right='" 
		. $menu_right . "', position_right_units="  . $menu_right_units . ", display='block', z_index=" . $menu_z_index . $menu_width_str;
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_a" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_1_text_align . "', padding_top="
		. $sub_level_1_padding_top . ", padding_top_units=" . $sub_level_1_padding_top_units
		. ", padding_right=" . $sub_level_1_padding_right . ", padding_right_units=" . $sub_level_1_padding_right_units
		. ", padding_bottom=" . $sub_level_1_padding_bottom . ", padding_bottom_units=" . $sub_level_1_padding_bottom_units
		. ", padding_left=" . $sub_level_1_padding_left . ", padding_left_units=" . $sub_level_1_padding_left_units
		. ", width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units
		. ", line_height=" . $sub_level_1_item_height . ", line_height_units=" . $sub_level_1_item_height_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_a" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
		. "', class='.sub_level_1_a" . $suffix . "', use_table_data=1, text_align='" . $sub_level_1_text_align
		. "', width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units
		. ", line_height=" . $sub_level_1_item_height . ", line_height_units=" . $sub_level_1_item_height_units
		. ", padding_top=" . $sub_level_1_padding_top . ", padding_top_units=" . $sub_level_1_padding_top_units
		. ", padding_right=" . $sub_level_1_padding_right . ", padding_right_units=" . $sub_level_1_padding_right_units
		. ", padding_bottom=" . $sub_level_1_padding_bottom . ", padding_bottom_units=" . $sub_level_1_padding_bottom_units
		. ", padding_left=" . $sub_level_1_padding_left . ", padding_left_units=" . $sub_level_1_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_li" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	if ($sub_level_1_orientation == "horizontal")
		$float_str = "left";
	else
		$float_str = "-not selected-";
		
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_1_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_1_item_spacing . ", margin_bottom_units=" . $sub_level_1_item_spacing_units 
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_1_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_1_item_spacing . ", margin_right_units=" . $sub_level_1_item_spacing_units 
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_1_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_1_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_1_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_1_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_1_item_spacing . ", margin_bottom_units=" . $sub_level_1_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_1_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_1_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_1_item_spacing . ", margin_right_units=" . $sub_level_1_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_li_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_1_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_1_item_spacing . ", margin_bottom_units=" . $sub_level_1_item_spacing_units 
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_1_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li_down" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_1_item_spacing . ", margin_right_units=" . $sub_level_1_item_spacing_units 
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_1_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li_down" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_1_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_1_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_1_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_1_item_spacing . ", margin_bottom_units=" . $sub_level_1_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_1_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_1_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_1_item_spacing . ", margin_right_units=" . $sub_level_1_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_a_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.		
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_1_text_align . "', padding_top="
		. $sub_level_1_padding_top . ", padding_top_units=" . $sub_level_1_padding_top_units
		. ", padding_right=" . $sub_level_1_padding_right . ", padding_right_units=" . $sub_level_1_padding_right_units
		. ", padding_bottom=" . $sub_level_1_padding_bottom . ", padding_bottom_units=" . $sub_level_1_padding_bottom_units
		. ", padding_left=" . $sub_level_1_padding_left . ", padding_left_units=" . $sub_level_1_padding_left_units
		. ", width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units
		. ", line_height=" . $sub_level_1_item_height . ", line_height_units=" . $sub_level_1_item_height_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_a_down" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
		. "', class='.sub_level_1_a_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_1_text_align
		. "', width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units
		. ", line_height=" . $sub_level_1_item_height . ", line_height_units=" . $sub_level_1_item_height_units
		. ", padding_top=" . $sub_level_1_padding_top . ", padding_top_units=" . $sub_level_1_padding_top_units
		. ", padding_right=" . $sub_level_1_padding_right . ", padding_right_units=" . $sub_level_1_padding_right_units
		. ", padding_bottom=" . $sub_level_1_padding_bottom . ", padding_bottom_units=" . $sub_level_1_padding_bottom_units
		. ", padding_left=" . $sub_level_1_padding_left . ", padding_left_units=" . $sub_level_1_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_a" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_a" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_a" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_li" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	if ($sub_level_2_orientation == "horizontal")
		$float_str = "left";
	else
		$float_str = "-not selected-";
	
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units 
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_2_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_2_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_li" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_3_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_3_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_li" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_4_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_4_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_5_li" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_5_li" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_5_li" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_5_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_5_li" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_li_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units 
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li_down" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li_down" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_2_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_2_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_li_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li_down" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li_down" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_3_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_3_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_li_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li_down" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li_down" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_4_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_4_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_5_li_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units
			. ", margin_right=-1000000, margin_right_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_5_li_down" . $suffix . "'";
		}
		else	{
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1"
			. ", margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units
			. ", margin_bottom=-1000000, margin_bottom_units=0, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_5_li_down" . $suffix . "'";
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_2_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_5_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_bottom=" . $sub_level_2_item_spacing . ", margin_bottom_units=" . $sub_level_2_item_spacing_units . ", margin_right=-1000000, margin_right_units=0";
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu 
			. "', class='.sub_level_5_li_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align . "', `float`='" . $float_str
			. "', margin_right=" . $sub_level_2_item_spacing . ", margin_right_units=" . $sub_level_2_item_spacing_units . ", margin_bottom=-1000000, margin_bottom_units=0";
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_a_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_a_down" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_a_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_a" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_a" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_a" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_a_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_a_down" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_a_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_a" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_a" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_a" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_a_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_a_down" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_a_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_5_a" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_5_a" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_5_a" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_5_a_down" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_5_a_down" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_5_a_down" . $suffix . "', use_table_data=1, text_align='" . $sub_level_2_text_align
		. "', width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units
		. ", line_height=" . $sub_level_2_item_height . ", line_height_units=" . $sub_level_2_item_height_units 
		. ", padding_top=" . $sub_level_2_padding_top . ", padding_top_units=" . $sub_level_2_padding_top_units
		. ", padding_right=" . $sub_level_2_padding_right . ", padding_right_units=" . $sub_level_2_padding_right_units
		. ", padding_bottom=" . $sub_level_2_padding_bottom . ", padding_bottom_units=" . $sub_level_2_padding_bottom_units
		. ", padding_left=" . $sub_level_2_padding_left . ", padding_left_units=" . $sub_level_2_padding_left_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.top_level_li_down" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	if ($sub_level_1_orientation == "horizontal")	{
		$position_str = "absolute";
		if (($sub_level_collapse == true) && ($top_down_on_sub_down != 1))	{
			if ($sub_level_1_transitions === true)
				$display_str = "block";
			else
				$display_str = "none";
		}
		else
			$display_str = "flex";
		$hover_display_str = "flex";
	}
	else	{
		if ($sub_level_1_transitions === true)
			$position_str = "absolute";
		else
			$position_str = "-not selected-";
			
		if (($sub_level_collapse == true) && ($top_down_on_sub_down != 1))	{
			if ($sub_level_1_transitions === true)
				$display_str = "block";
			else
				$display_str = "none";
		}
		else
			$display_str = "block";
		$hover_display_str = "block";
	}

	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, position='" . $position_str . "', display='" . $display_str
		. "', margin_top=" . $sub_level_1_offset_top . ", margin_top_units=" . $sub_level_1_offset_top_units 
		. ", margin_left=" . $sub_level_1_offset_left . ", margin_left_units=" . $sub_level_1_offset_left_units
		. $height_width_overflow_border_width_str
		. ", transition_property='" . $sub_level_1_transition_property . "', transition_timing_function='" . $sub_level_1_transition_timing_function
		. "', transition_duration=" . $sub_level_1_transition_duration . ", transition_duration_units=" . $sub_level_1_transition_duration_units
		. ", transition_delay=" . $sub_level_1_transition_delay . ", transition_delay_units=" . $sub_level_1_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.top_level_li_down" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_li_down" . $suffix . " > ul', use_table_data=1, position='" 
		. $position_str . "', display='" . $display_str 
		. "', margin_top=" . $sub_level_1_offset_top . ", margin_top_units=" . $sub_level_1_offset_top_units 
		. ", margin_left=" . $sub_level_1_offset_left . ", margin_left_units=" . $sub_level_1_offset_left_units
		. $height_width_overflow_border_width_str
		. ", transition_property='" . $sub_level_1_transition_property . "', transition_timing_function='" . $sub_level_1_transition_timing_function
		. "', transition_duration=" . $sub_level_1_transition_duration . ", transition_duration_units=" . $sub_level_1_transition_duration_units
		. ", transition_delay=" . $sub_level_1_transition_delay . ", transition_delay_units=" . $sub_level_1_transition_delay_units;
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.top_level_li" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();

	if ($sub_level_1_transition_property != "-not selected-")	{
		if ($orientation == "vertical")	{
			if (($sub_level_1_item_width != -1) && ($sub_level_1_orientation == "vertical") && ($sub_level_2_orientation != "horizontal"))
				$width_str = ", width=0, width_units=14, min_width=" . $sub_level_1_item_width . ", min_width_units=" . $sub_level_1_item_width_units . ", max_width=0, max_width_units=14";
			elseif (($sub_level_1_orientation == "vertical") && ($sub_level_2_orientation == "horizontal"))
				$width_str = ", width=0, width_units=14, min_width=100, min_width_units=10, max_width=-1, max_width_units=0";
			elseif ($sub_level_1_orientation == "vertical")
				$width_str = ", width=0, width_units=14, min_width=-1, min_width_units=0, max_width=100, max_width_units=10";
			else
				$width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0";
		}
		else	{
			if (($sub_level_1_item_width != -1) && ($sub_level_1_orientation == "vertical") && ($sub_level_2_orientation != "horizontal"))
				$width_str = ", width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units . ", min_width=-1, min_width_units=0, max_width=-1, max_width_units=0";
			else
				$width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0";
		}

		if (isset($sub_level_1_block_border_width) && ($sub_level_1_block_border_width > 0))	{
			$hover_border_str = ", border=" . $sub_level_1_block_border_width . ", border_sides=" . $sub_level_1_block_border_sides 
			. ", border_style='" . $sub_level_1_block_border_style . "', border_color='" . $sub_level_1_block_border_color . "'";
		}
		else
			$hover_border_str = ", border=-1, border_sides=0, border_style='-not selected-', border_color='-not set-'";

		if ($orientation == "vertical")	{
			if ($sub_level_1_orientation == "vertical")
				$height_width_border_str = $width_str . ", height=-1, height_units=0, max_height=-1, max_height_units=0" . $hover_border_str;
			elseif ($sub_level_1_item_height != -1)
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=" . $sub_level_1_item_height . ", max_height_units=" . $sub_level_1_item_height_units . $hover_border_str;
			else
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=100, max_height_units=10" . $hover_border_str;
		}
		else	{
			if ($sub_level_1_orientation == "vertical")
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=100, max_height_units=10" . $hover_border_str;
			elseif ($sub_level_1_item_height != -1)
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=" . $sub_level_1_item_height . ", max_height_units=" . $sub_level_1_item_height_units . $hover_border_str;
			else
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=100, max_height_units=10" . $hover_border_str;
		}
	}
	else
		$height_width_border_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=-1, height_units=0, max_height=-1, max_height_units=0, border=-1, border_sides=0, border_style='-not selected-', border_color='-not set-'";

	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='" . $hover_display_str
		. "'" . $height_width_border_str . " WHERE style_sheet = '" . $menu . "' AND class='.top_level_li" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_li" . $suffix . ":hover > ul', use_table_data=1, display='" 
		. $hover_display_str . "'" . $height_width_border_str;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.top_level_li_down" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='" . $hover_display_str
		. "'" . $height_width_border_str . " WHERE style_sheet = '" . $menu . "' AND class='.top_level_li_down" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.top_level_li_down" . $suffix . ":hover > ul', use_table_data=1, display='" 
		. $hover_display_str . "'" . $height_width_border_str;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_li" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();

	if ($sub_level_2_transitions === true)	{
		$sub_level_2_transition_property = "width, height, min-width, min-height, max-width, max-height, border-width, font-size";
		if (isset($sub_level_2_block_border_width) && ($sub_level_2_block_border_width > 0))
			$border_str = ", border=0, border_units=0";
		else
			$border_str = ", border=-1, border_units=0";
		
		if ($sub_level_1_orientation == "vertical")	{
			if (($sub_level_2_orientation == "vertical") && ($orientation != "vertical"))
				$height_width_overflow_border_width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=0, height_units=14, max_height=0, max_height_units=0, overflow='hidden'" . $border_str;
			elseif ($sub_level_2_orientation == "vertical")
				$height_width_overflow_border_width_str = ", width=0, width_units=14, min_width=0, min_width_units=0, max_width=0, max_width_units=0, height=-1, height_units=0, max_height=-1, max_height_units=0, overflow='hidden'" . $border_str;
			else
				$height_width_overflow_border_width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=0, height_units=14, max_height=0, max_height_units=0, overflow='hidden'" . $border_str;
		}
		else		{
			if ($sub_level_2_orientation == "vertical")
				$height_width_overflow_border_width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=0, height_units=14, max_height=0, max_height_units=0, overflow='hidden'" . $border_str;
			else
				$height_width_overflow_border_width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=0, height_units=14, max_height=0, max_height_units=0, overflow='hidden'" . $border_str;
		}
	}
	else	{
		$sub_level_2_transition_property = "-not selected-";
		$height_width_overflow_border_width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=-1, height_units=0, max_height=-1, max_height_units=0, overflow='-not selected-', border=-1, border_units=0";
	}
			
	if ($sub_level_2_orientation == "horizontal")	{
		$display_str = ", display='flex'";
		$hover_display_str = ", display='flex'";
	}
	else	{
		if (($sub_level_collapse == true) && ($top_down_on_sub_down != 1))	{
			if ($sub_level_2_transitions === true)
				$display_str = ", display='block'";
			else
				$display_str = ", display='none'";
		}
		else
			$display_str = ", display='-not selected-'";
		$hover_display_str = ", display='block'";
	}

	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $display_str . $height_width_overflow_border_width_str
		. ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_1_li" . $suffix . " > ul', use_table_data=1" 
		. $display_str . $height_width_overflow_border_width_str . ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units;
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_li" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	if ($sub_level_2_transition_property != "-not selected-")	{
		if ($sub_level_1_orientation == "vertical")	{
			if (($sub_level_2_item_width != -1) && ($sub_level_2_orientation == "vertical") && ($orientation != "vertical"))
				$width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0";
			elseif (($sub_level_2_item_width != -1) && ($sub_level_2_orientation == "vertical"))
				$width_str = ", width=0, width_units=14, min_width=" . $sub_level_2_item_width . ", min_width_units=" . $sub_level_2_item_width_units . ", max_width=0, max_width_units=14";
			elseif ($sub_level_2_orientation == "vertical")
				$width_str = ", width=0, width_units=14, min_width=-1, min_width_units=0, max_width=100, max_width_units=10";
			else
				$width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=100, max_width_units=10";
		}
		else	{
			$width_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0";
		}
	
		if (isset($sub_level_2_block_border_width) && ($sub_level_2_block_border_width > 0))	{
			$hover_border_str = ", border=" . $sub_level_2_block_border_width . ", border_sides=" . $sub_level_2_block_border_sides 
			. ", border_style='" . $sub_level_2_block_border_style . "', border_color='" . $sub_level_2_block_border_color . "'";
		}
		else
			$hover_border_str = ", border=-1, border_sides=0, border_style='-not selected-', border_color='-not set-'";
	
		if ($sub_level_1_orientation == "vertical")	{
			if (($sub_level_2_orientation == "vertical") && ($orientation != "vertical"))
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=100, max_height_units=10" . $hover_border_str;
			elseif ($sub_level_2_orientation == "vertical")
				$height_width_border_str = $width_str . ", height=-1, height_units=0, max_height=-1, max_height_units=0" . $hover_border_str;
			elseif ($sub_level_2_item_height != -1)
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=" . $sub_level_2_item_height . ", max_height_units=" . $sub_level_2_item_height_units . $hover_border_str;
			else
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=100, max_height_units=10" . $hover_border_str;
		}
		else	{
			if ($sub_level_2_orientation == "vertical")
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=100, max_height_units=10" . $hover_border_str;
			elseif ($sub_level_2_item_height != -1)
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=" . $sub_level_2_item_height . ", max_height_units=" . $sub_level_2_item_height_units . $hover_border_str;
			else
				$height_width_border_str = $width_str . ", height=0, height_units=14, max_height=100, max_height_units=10" . $hover_border_str;
		}
	}
	else
		$height_width_border_str = ", width=-1, width_units=0, min_width=-1, min_width_units=0, max_width=-1, max_width_units=0, height=-1, height_units=0, max_height=-1, max_height_units=0, border=-1, border_sides=0, border_style='-not selected-', border_color='-not set-'";

	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $hover_display_str . $height_width_border_str
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_1_li" . $suffix . ":hover > ul', use_table_data=1" 
		. $hover_display_str . $height_width_border_str;
	}
//	echo $query . "\n";
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_li_down" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $display_str . $height_width_overflow_border_width_str
		. ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li_down" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_1_li_down" . $suffix . " > ul', use_table_data=1" 
		. $display_str . $height_width_overflow_border_width_str . ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_li_down" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $hover_display_str 
		. $height_width_border_str . " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li_down" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_1_li_down" . $suffix . ":hover > ul', use_table_data=1" 
		. $hover_display_str . $height_width_border_str;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_li" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $display_str . $height_width_overflow_border_width_str
		. ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_li" . $suffix . " > ul', use_table_data=1" 
		. $display_str . $height_width_overflow_border_width_str . ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_li" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $hover_display_str . $height_width_border_str
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_li" . $suffix . ":hover > ul', use_table_data=1" 
		. $hover_display_str . $height_width_border_str;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_li_down" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $display_str . $height_width_overflow_border_width_str
		. ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li_down" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_li_down" . $suffix . " > ul', use_table_data=1" 
		. $display_str . $height_width_overflow_border_width_str . ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_li_down" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $hover_display_str
		. $height_width_border_str . " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li_down" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_li_down" . $suffix . ":hover > ul', use_table_data=1" 
		. $hover_display_str . $height_width_border_str;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_li" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $display_str . $height_width_overflow_border_width_str
		. ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_li" . $suffix . " > ul', use_table_data=1" 
		. $display_str . $height_width_overflow_border_width_str . ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_li" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $hover_display_str . $height_width_border_str
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_li" . $suffix . ":hover > ul', use_table_data=1" 
		. $hover_display_str . $height_width_border_str;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_li_down" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $display_str . $height_width_overflow_border_width_str
		. ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li_down" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_li_down" . $suffix . " > ul', use_table_data=1" 
		. $display_str . $height_width_overflow_border_width_str . ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_li_down" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $hover_display_str
		. $height_width_border_str . " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li_down" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_li_down" . $suffix . ":hover > ul', use_table_data=1" 
		. $hover_display_str . $height_width_border_str;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_li" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $display_str . $height_width_overflow_border_width_str
		. ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_li" . $suffix . " > ul', use_table_data=1" 
		. $display_str . $height_width_overflow_border_width_str . ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_li" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $hover_display_str . $height_width_border_str
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_li" . $suffix . ":hover > ul', use_table_data=1" 
		. $hover_display_str . $height_width_border_str;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_li_down" . $suffix . " > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $display_str . $height_width_overflow_border_width_str
		. ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units
		. " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li_down" . $suffix . " > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_li_down" . $suffix . " > ul', use_table_data=1" 
		. $display_str . $height_width_overflow_border_width_str . ", margin_top=" . $sub_level_2_offset_top . ", margin_top_units=" . $sub_level_2_offset_top_units
		. ", margin_left=" . $sub_level_2_offset_left . ", margin_left_units=" . $sub_level_2_offset_left_units
		. ", transition_property='" . $sub_level_2_transition_property . "', transition_timing_function='" . $sub_level_2_transition_timing_function
		. "', transition_duration=" . $sub_level_2_transition_duration . ", transition_duration_units=" . $sub_level_2_transition_duration_units
		. ", transition_delay=" . $sub_level_2_transition_delay . ", transition_delay_units=" . $sub_level_2_transition_delay_units;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_li_down" . $suffix . ":hover > ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1" . $hover_display_str
		. $height_width_border_str . " WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li_down" . $suffix . ":hover > ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_li_down" . $suffix . ":hover > ul', use_table_data=1" 
		. $hover_display_str . $height_width_border_str;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_li" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	if ($sub_level_1_orientation == "horizontal")
		$float_str = "left";
	else
		$float_str = "-not selected-";
		
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_1_li" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_li_down" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_1_li_down" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_1_li_down" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_li" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	if ($sub_level_2_orientation == "horizontal")
		$float_str = "left";
	else
		$float_str = "-not selected-";
		
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_li" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_li_down" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_2_li_down" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_li_down" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_li" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_li" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_li_down" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_3_li_down" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_li_down" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_li" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_li" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_li_down" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_4_li_down" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_li_down" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_5_li" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_5_li" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_5_li" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_5_li_down" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, `float`='" . $float_str
		. "' WHERE style_sheet = '" . $menu . "' AND class='.sub_level_5_li_down" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_5_li_down" . $suffix . ":hover', use_table_data=1, `float`='" 
		. $float_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_ul" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	
	if (($sub_level_1_transitions === true) || ($sub_level_2_transitions === true))
		$ul_position_str = "-not selected-";
	else
		$ul_position_str = "absolute";
		
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, position='" . $ul_position_str . "' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_1_ul" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_1_ul" . $suffix 
		. "', use_table_data=1, position='" . $ul_position_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_ul" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
		
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, position='" . $ul_position_str . "' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_2_ul" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_ul" . $suffix 
		. "', use_table_data=1, position='" . $ul_position_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_ul" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, position='" . $ul_position_str . "' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_3_ul" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_ul" . $suffix 
		. "', use_table_data=1, position='" . $ul_position_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_ul" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, position='" . $ul_position_str . "' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_4_ul" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_ul" . $suffix 
		. "', use_table_data=1, position='" . $ul_position_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_5_ul" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, position='" . $ul_position_str . "' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_5_ul" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_5_ul" . $suffix 
		. "', use_table_data=1, position='" . $ul_position_str . "'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_1_ul" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='block' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_1_ul" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_1_ul" . $suffix 
		. ":hover', use_table_data=1, display='block'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_2_ul" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='block' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_2_ul" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_2_ul" . $suffix 
		. ":hover', use_table_data=1, display='block'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_3_ul" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='block' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_3_ul" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_3_ul" . $suffix 
		. ":hover', use_table_data=1, display='block'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_4_ul" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='block' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_4_ul" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_4_ul" . $suffix 
		. ":hover', use_table_data=1, display='block'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.sub_level_5_ul" . $suffix . ":hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, display='block' WHERE style_sheet = '"
		. $menu . "' AND class='.sub_level_5_ul" . $suffix . ":hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.sub_level_5_ul" . $suffix 
		. ":hover', use_table_data=1, display='block'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.menu_div" . $suffix . ":hover .top_level_li" . $suffix . "::after'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	$sub_level_1_offset_top_line_height_units = (int)$sub_level_1_offset_top_units + 2;
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=0 WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .top_level_li" . $suffix . "::after'";	
		if ($orientation == "vertical")	{
			if ($sub_level_1_offset_left != -1000000)	{
				$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $top_level_item_height
				. ", line_height_units=" . $top_level_item_height_units . ", font_size=0, font_size_units='px', position='absolute', position_right=-" 
				. $sub_level_1_offset_left . ", position_right_units=" . $sub_level_1_offset_left_units . ", position_left=-1000000, position_left_units=0"
				. ", position_bottom=-" . $sub_level_1_offset_top . ", position_bottom_units=" . $sub_level_1_offset_top_units 
				. ", width=" . $sub_level_1_offset_left . ", width_units=" . $sub_level_1_offset_left_units . " WHERE style_sheet = '"
				. $menu . "' AND class='.menu_div" . $suffix . ":hover .top_level_li" . $suffix . "::after'";
			}
		}
		else	{
			if ($sub_level_1_offset_top != -1000000)	{
				$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_1_offset_top
				. ", line_height_units=" . $sub_level_1_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
				. $sub_level_1_offset_top . ", position_bottom_units=" . $sub_level_1_offset_top_units . ", position_right=-1000000, position_right_units=0"
				. ", position_left=0, position_left_units=0, width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units . " WHERE style_sheet = '"
				. $menu . "' AND class='.menu_div" . $suffix . ":hover .top_level_li" . $suffix . "::after'";
			}
		}
	}
	else
	{
		//Insert new data into table.
		if ($orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .top_level_li" . $suffix 
			. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $top_level_item_height
			. ", line_height_units=" . $top_level_item_height_units . ", font_size=0, font_size_units='px', position='absolute', position_right=-" 
			. $sub_level_1_offset_left . ", position_right_units=" . $sub_level_1_offset_left_units
			. ", position_bottom=-" . $sub_level_1_offset_top . ", position_bottom_units=" . $sub_level_1_offset_top_units
			. ", width=" . $sub_level_1_offset_left . ", width_units=" . $sub_level_1_offset_left_units;
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .top_level_li" . $suffix 
			. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_1_offset_top
			. ", line_height_units=" . $sub_level_1_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
			. $sub_level_1_offset_top . ", position_bottom_units=" . $sub_level_1_offset_top_units
			. ", position_left=0, position_left_units=0, width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units;
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.menu_div" . $suffix . ":hover .top_level_li_down" . $suffix . "::after'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=0 WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .top_level_li_down" . $suffix . "::after'";	
		if ($orientation == "vertical")	{
			if ($sub_level_1_offset_left != -1000000)	{
				$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $top_level_item_height
				. ", line_height_units=" . $top_level_item_height_units . ", font_size=0, font_size_units='px', position='absolute', position_right=-" 
				. $sub_level_1_offset_left . ", position_right_units=" . $sub_level_1_offset_left_units . ", position_left=-1000000, position_left_units=0"
				. ", position_bottom=-" . $sub_level_1_offset_top . ", position_bottom_units=" . $sub_level_1_offset_top_units 
				. ", width=" . $sub_level_1_offset_left . ", width_units=" . $sub_level_1_offset_left_units 
				. " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .top_level_li_down" . $suffix . "::after'";
			}
		}
		else	{
			if ($sub_level_1_offset_top != -1000000)	{
				$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_1_offset_top
				. ", line_height_units=" . $sub_level_1_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
				. $sub_level_1_offset_top . ", position_bottom_units=" . $sub_level_1_offset_top_units . ", position_right=-1000000, position_right_units=0"
				. ", position_left=0, position_left_units=0, width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units . " WHERE style_sheet = '"
				. $menu . "' AND class='.menu_div" . $suffix . ":hover .top_level_li_down" . $suffix . "::after'";
			}
		}
	}
	else
	{
		//Insert new data into table.
		if ($orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .top_level_li_down" . $suffix 
			. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $top_level_item_height
			. ", line_height_units=" . $top_level_item_height_units . ", font_size=0, font_size_units='px', position='absolute', position_right=-" 
			. $sub_level_1_offset_left . ", position_right_units=" . $sub_level_1_offset_left_units
			. ", position_bottom=-" . $sub_level_1_offset_top . ", position_bottom_units=" . $sub_level_1_offset_top_units 
			. ", width=" . $sub_level_1_offset_left . ", width_units=" . $sub_level_1_offset_left_units;
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .top_level_li_down" . $suffix 
			. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_1_offset_top
			. ", line_height_units=" . $sub_level_1_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
			. $sub_level_1_offset_top . ", position_bottom_units=" . $sub_level_1_offset_top_units
			. ", position_left=0, position_left_units=0, width=" . $top_level_item_width . ", width_units=" . $top_level_item_width_units;
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.menu_div" . $suffix . ":hover .sub_level_1_li" . $suffix . "::after'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	$sub_level_2_offset_top_line_height_units = (int)$sub_level_2_offset_top_units + 2;
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=0 WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_1_li" . $suffix . "::after'";
		if ($sub_level_1_orientation == "vertical")	{
			if ($sub_level_2_offset_top != -1000000)	{
				$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
				. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
				. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units . ", position_right=-1000000, position_right_units=0"
				. ", position_left=0, position_left_units=0, width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units 
				. " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_1_li" . $suffix . "::after'";
			}
		}
		else	{	
			if ($sub_level_2_offset_left != -1000000)	{
				$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
				. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_right=0, position_right_units=0, position_bottom=-" . $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units 
				. ", position_left=-1000000, position_left_units=0, width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units 
				. " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_1_li" . $suffix . "::after'";
			}
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_1_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .sub_level_1_li" . $suffix 
			. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
			. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
			. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units
			. ", position_left=0, position_left_units=0, width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units;
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .sub_level_1_li" . $suffix 
			. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top 
			. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
			. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units . ", position_right=0, position_right_units=0"
			. ", width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units;
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.menu_div" . $suffix . ":hover .sub_level_1_li_down" . $suffix . "::after'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=0 WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_1_li_down" . $suffix . "::after'";
		if ($sub_level_1_orientation == "vertical")	{
			if ($sub_level_2_offset_top != -1000000)	{
				$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
				. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
				. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units . ", position_right=-1000000, position_right_units=0"
				. ", position_left=0, position_left_units=0, width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units 
				. " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_1_li_down" . $suffix . "::after'";
			}
		}
		else	{	
			if ($sub_level_2_offset_left != -1000000)	{
				$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
				. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_right=0, position_right_units=0, position_bottom=-" . $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units 
				. ", position_left=-1000000, position_left_units=0, width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units 
				. " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_1_li_down" . $suffix . "::after'";
			}
		}
	}
	else
	{
		//Insert new data into table.
		if ($sub_level_1_orientation == "vertical")	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .sub_level_1_li_down" . $suffix 
			. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
			. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
			. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units
			. ", position_left=0, position_left_units=0, width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units;
		}
		else	{
			$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .sub_level_1_li_down" . $suffix 
			. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top 
			. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
			. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units . ", position_right=0, position_right_units=0"
			. ", width=" . $sub_level_1_item_width . ", width_units=" . $sub_level_1_item_width_units;
		}
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	for ($i = 2; $i < 5; $i++)
	{
		$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li" . $suffix . "::after'";
		$result = $bwb_dbh->query($query);
		$row_count = $result->rowCount();
		if ($row_count > 0)
		{
			//Update class record.
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=0 WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li" . $suffix . "::after'";
			if ($sub_level_2_orientation == "vertical")	{
				if ($sub_level_2_offset_top != -1000000)	{
					$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
					. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
					. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units . ", position_right=-1000000, position_right_units=0"
					. ", position_left=0, position_left_units=0, width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units 
					. " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li" . $suffix . "::after'";
				}
			}
			else	{	
				if ($sub_level_2_offset_left != -1000000)	{
					$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
					. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_right=0, position_right_units=0, position_bottom=-" . $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units 
					. ", position_left=-1000000, position_left_units=0, width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units 
					. " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li" . $suffix . "::after'";
				}
			}
		}
		else
		{
			//Insert new data into table.
			if ($sub_level_2_orientation == "vertical")	{
				$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li" . $suffix 
				. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
				. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
				. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units
				. ", position_left=0, position_left_units=0, width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units;
			}
			else	{
				$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li" . $suffix 
				. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top 
				. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
				. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units . ", position_right=0, position_right_units=0"
				. ", width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units;
			}
		}
		$cnt = $bwb_dbh->exec($query);
	}
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	for ($i = 2; $i < 5; $i++)
	{
		$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li_down" . $suffix . "::after'";
		$result = $bwb_dbh->query($query);
		$row_count = $result->rowCount();
		if ($row_count > 0)
		{
			//Update class record.
			$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=0 WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li_down" . $suffix . "::after'";
			if ($sub_level_2_orientation == "vertical")	{
				if ($sub_level_2_offset_top != -1000000)	{
					$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
					. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
					. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units . ", position_right=-1000000, position_right_units=0"
					. ", position_left=0, position_left_units=0, width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units 
					. " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li_down" . $suffix . "::after'";
				}
			}
			else	{	
				if ($sub_level_2_offset_left != -1000000)	{
					$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
					. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_right=0, position_right_units=0, position_bottom=-" . $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units 
					. ", position_left=-1000000, position_left_units=0, width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units 
					. " WHERE style_sheet = '" . $menu . "' AND class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li_down" . $suffix . "::after'";
				}
			}
		}
		else
		{
			//Insert new data into table.
			if ($sub_level_2_orientation == "vertical")	{
				$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li_down" . $suffix 
				. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top
				. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
				. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units
				. ", position_left=0, position_left_units=0, width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units;
			}
			else	{
				$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix . ":hover .sub_level_" . $i . "_li_down" . $suffix 
				. "::after', use_table_data=1, content='string', content_text='.', line_height=" . $sub_level_2_offset_top 
				. ", line_height_units=" . $sub_level_2_offset_top_line_height_units . ", font_size=0, font_size_units='px', position='absolute', position_bottom=-" 
				. $sub_level_2_offset_top . ", position_bottom_units=" . $sub_level_2_offset_top_units . ", position_right=0, position_right_units=0"
				. ", width=" . $sub_level_2_item_width . ", width_units=" . $sub_level_2_item_width_units;
			}
		}
		$cnt = $bwb_dbh->exec($query);
	}
	
	////////////////////////////// Adjustments to allow gaps between menus and menu items //////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . "site_css WHERE `style_sheet` = '" . $menu . "' AND `class` = '.menu_div" . $suffix . " li:last-of-type'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . "site_css SET use_table_data=1, margin_bottom=0, margin_bottom_units=0 WHERE style_sheet = '"
		. $menu . "' AND class='.menu_div" . $suffix . " li:last-of-type'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "site_css SET style_sheet = '" . $menu . "', class='.menu_div" . $suffix 
		. " li:last-of-type', use_table_data=1, margin_bottom=0, margin_bottom_units=0";
	}
	$cnt = $bwb_dbh->exec($query);

	//////////////////////////////////////////////////////////////////////////////////////////
	//Update menu list for proportional widths.
	$query = "UPDATE " . BWB_TABLE_PREFIX . "menus SET proportional=" . $proportional_width_top . ", proportional_sub=" . $proportional_width_sub . ", top_down_on_sub_down=" . $top_down_on_sub_down . " WHERE menu_name='" . $menu . "'";
	$cnt = $bwb_dbh->exec($query);


	/////////////////////////////////////////////
	// Build string for site.css file /////
	$css_string = BuildCSSString($menu, $bwb_dbh, BWB_BASE_DIR, BWB_IMAGE_DIR, BWB_TABLE_PREFIX);
			

	////////////////////////////////////////////////////////
	/// Write menu items to menu.css file /////////////
	//Test to see if file already exists.
	$document_root = $_SERVER['DOCUMENT_ROOT'];
	if (BWB_BASE_DIR == '')
		$userfiles = '';
	else
		$userfiles = "/" . BWB_BASE_DIR;
		
	$file_name = $document_root . $userfiles . "/" . BWB_CSS_DIR . "/" . $css_file;
		
	if (file_exists($file_name))
	{
		$bkup_file_name = $file_name . time();
		if (!rename($file_name, $bkup_file_name))
			echo ADD_PLUGIN_TO_PAGE_COULD_NOT_RENAME_MSG . " $file_name " . TO_WORD ." $bkup_file_name.<br>";
		@chmod($bkup_file_name, 0644);
	}
	
	// Create file.
	$fh = fopen($file_name, 'x') or die(UPLOAD_TEMPLATE_CANT_CREATE_ERR . " $file_name: $php_errormsg");
	$result = (fputs($fh, $css_string));
	fclose($fh) or die($php_errormsg);
	@chmod($file_name, 0644);
	
	echo 1;
?>
