<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 10/26/2009		ELL
// Modified: 1/6/2010		ELL
// Added z-indexing to fix bug of sublevels not popping above main level upon hover.
// Modified: 1/7/2010		ELL
// Changed the way hover text color is handled.  Was able to add separate user-electable sublevel 2 hover text color.
// Added contlol of visited:hover text color so the visited menu links will be forced to same color as non-visited links for default
// whether mouse-out or hover.
// Added display block to ".top_level_li A" class to get link to encompass entire list-item area and not just text.
// Note: This fix also fixes the problem with IE7 not positioning submenu items properly.
// Revised: 10/7/2010	ELL
// Added code to allow top, bottom, left and right of border to be selected independantly in any combination when setting
// border styles.
// Revised: 1/10/2011	ELL
// Added preview mode.
// Revised: 2/10/2012	ELL
// Added table prefix handling.  Added references to CSS folder configurations.
// Revised: 7/21/2013	ELL
// Added background opacity.
// Revised: 3/10/2015	ELL
// Converted deprecated font stretch to letter spacing.
// Revised: 4/5/2015	ELL
// Added font size units.
// Converted save operation to AJAX.
// Revamped preview to show actual popup page.
// Revised: 10/3/2016	ELL
// Add display = block to .top_level_ax to cause click area to cover full button instead of just text.
//
	include ("check_session.php");
	include ("lib/copy_table.php");
	include("lib/build_css_string.php");
		
	$operation = $_POST['operation'];
	$menu = $_REQUEST['menu'];
	$tmp = str_replace("_mobile", "", $menu);
	$suffix = substr($tmp, 4);
	$class_table = $menu . "_classes";
	
	if ($operation == "Preview")
	{
		$site_css_table = "menu_styles_preview";
		$css_file = "menu_styles_preview.css";
		
		$query = "TRUNCATE TABLE " . BWB_TABLE_PREFIX . $site_css_table;
		$cnt = $bwb_dbh->exec($query);
		$src_table = $menu . "_css";
		copy_table(BWB_TABLE_PREFIX . $src_table, BWB_TABLE_PREFIX . $site_css_table, $bwb_dbh, $bwb_database);
	}
	else
	{
		$site_css_table = $menu . "_css";
		$css_file = $menu . ".css";
	}
	
	if (isset($_POST["top_level_font"])) $top_level_font = $_POST["top_level_font"];
	else $top_level_font = "-not selected-";
	if (is_numeric($_POST["top_level_font_size"])) $top_level_font_size = $_POST["top_level_font_size"];
	else $top_level_font_size = -1;
	if (isset($_POST["top_level_font_size_units"])) $top_level_font_size_units = $_POST["top_level_font_size_units"];
	else $top_level_font_size_units = "px";
	if (isset($_POST["top_level_weight"])) $top_level_weight = $_POST["top_level_weight"];
	else $top_level_weight = "-not selected-";
	if (isset($_POST["top_level_letter_spacing"])) $top_level_letter_spacing = $_POST["top_level_letter_spacing"];
	else $top_level_letter_spacing = "-not selected-";
	if (isset($_POST["top_level_letter_spacing_units"])) $top_level_letter_spacing_units = $_POST["top_level_letter_spacing_units"];
	else $top_level_letter_spacing_units = "-not selected-";	
	if (is_numeric($_POST["top_level_italic"])) $top_level_italic = $_POST["top_level_italic"];
	else $top_level_italic = 0;
	if (is_numeric($_POST["top_level_underline"])) $top_level_underline = $_POST["top_level_underline"];
	else $top_level_underline = 0;
	if (is_numeric($_POST["top_level_overline"])) $top_level_overline = $_POST["top_level_overline"];
	else $top_level_overline = 0;
	if (is_numeric($_POST["top_level_blink"])) $top_level_blink = $_POST["top_level_blink"];
	else $top_level_blink = 0;
	if (is_numeric($_POST["top_level_oblique"])) $top_level_oblique = $_POST["top_level_oblique"];
	else $top_level_oblique = 0;
	if (is_numeric($_POST["top_level_small_caps"])) $top_level_small_caps = $_POST["top_level_small_caps"];
	else $top_level_small_caps = 0;
	if (is_numeric($_POST["top_level_shadow"])) $top_level_shadow = $_POST["top_level_shadow"];
	else $top_level_shadow = 0;
	if (isset($_POST["top_level_shadow_color"])) $top_level_shadow_color = $_POST["top_level_shadow_color"];
	else $top_level_shadow_color = "-not set-";
	if (is_numeric($_POST["top_level_shadow_x_offset"])) $top_level_shadow_x_offset = $_POST["top_level_shadow_x_offset"];
	else $top_level_shadow_x_offset = 0;
	if (is_numeric($_POST["top_level_shadow_y_offset"])) $top_level_shadow_y_offset = $_POST["top_level_shadow_y_offset"];
	else $top_level_shadow_y_offset = 0;
	if (is_numeric($_POST["top_level_shadow_blur"])) $top_level_shadow_blur = $_POST["top_level_shadow_blur"];
	else $top_level_shadow_blur = 0;
	if (isset($_POST["top_level_text_color"])) $top_level_text_color = $_POST["top_level_text_color"];
	else $top_level_text_color = "-not set-";
	
	if (isset($_POST["sub_level_1_font"])) $sub_level_1_font = $_POST["sub_level_1_font"];
	else $sub_level_1_font = "-not selected-";
	if (is_numeric($_POST["sub_level_1_font_size"])) $sub_level_1_font_size = $_POST["sub_level_1_font_size"];
	else $sub_level_1_font_size = -1;
	if (isset($_POST["sub_level_1_font_size_units"])) $sub_level_1_font_size_units = $_POST["sub_level_1_font_size_units"];
	else $sub_level_1_font_size_units = "px";
	if (isset($_POST["sub_level_1_weight"])) $sub_level_1_weight = $_POST["sub_level_1_weight"];
	else $sub_level_1_weight = "-not selected-";
	if (isset($_POST["sub_level_1_letter_spacing"])) $sub_level_1_letter_spacing = $_POST["sub_level_1_letter_spacing"];
	else $sub_level_1_letter_spacing = "-not selected-";
	if (isset($_POST["sub_level_1_letter_spacing_units"])) $sub_level_1_letter_spacing_units = $_POST["sub_level_1_letter_spacing_units"];
	else $sub_level_1_letter_spacing_units = "-not selected-";	
	if (is_numeric($_POST["sub_level_1_italic"])) $sub_level_1_italic = $_POST["sub_level_1_italic"];
	else $sub_level_1_italic = 0;
	if (is_numeric($_POST["sub_level_1_underline"])) $sub_level_1_underline = $_POST["sub_level_1_underline"];
	else $sub_level_1_underline = 0;
	if (is_numeric($_POST["sub_level_1_overline"])) $sub_level_1_overline = $_POST["sub_level_1_overline"];
	else $sub_level_1_overline = 0;
	if (is_numeric($_POST["sub_level_1_blink"])) $sub_level_1_blink = $_POST["sub_level_1_blink"];
	else $sub_level_1_blink = 0;
	if (is_numeric($_POST["sub_level_1_oblique"])) $sub_level_1_oblique = $_POST["sub_level_1_oblique"];
	else $sub_level_1_oblique = 0;
	if (is_numeric($_POST["sub_level_1_small_caps"])) $sub_level_1_small_caps = $_POST["sub_level_1_small_caps"];
	else $sub_level_1_small_caps = 0;
	if (is_numeric($_POST["sub_level_1_shadow"])) $sub_level_1_shadow = $_POST["sub_level_1_shadow"];
	else $sub_level_1_shadow = 0;
	if (isset($_POST["sub_level_1_shadow_color"])) $sub_level_1_shadow_color = $_POST["sub_level_1_shadow_color"];
	else $sub_level_1_shadow_color = "-not set-";
	if (is_numeric($_POST["sub_level_1_shadow_x_offset"])) $sub_level_1_shadow_x_offset = $_POST["sub_level_1_shadow_x_offset"];
	else $sub_level_1_shadow_x_offset = 0;
	if (is_numeric($_POST["sub_level_1_shadow_y_offset"])) $sub_level_1_shadow_y_offset = $_POST["sub_level_1_shadow_y_offset"];
	else $sub_level_1_shadow_y_offset = 0;
	if (is_numeric($_POST["sub_level_1_shadow_blur"])) $sub_level_1_shadow_blur = $_POST["sub_level_1_shadow_blur"];
	else $sub_level_1_shadow_blur = 0;
	if (isset($_POST["sub_level_1_text_color"])) $sub_level_1_text_color = $_POST["sub_level_1_text_color"];
	else $sub_level_1_text_color = "-not set-";
	
	if (isset($_POST["sub_level_2_font"])) $sub_level_2_font = $_POST["sub_level_2_font"];
	else $sub_level_2_font = "-not selected-";
	if (is_numeric($_POST["sub_level_2_font_size"])) $sub_level_2_font_size = $_POST["sub_level_2_font_size"];
	else $sub_level_2_font_size = -1;
	if (isset($_POST["sub_level_2_font_size_units"])) $sub_level_2_font_size_units = $_POST["sub_level_2_font_size_units"];
	else $sub_level_2_font_size_units = "px";
	if (isset($_POST["sub_level_2_weight"])) $sub_level_2_weight = $_POST["sub_level_2_weight"];
	else $sub_level_2_weight = "-not selected-";
	if (isset($_POST["sub_level_2_letter_spacing"])) $sub_level_2_letter_spacing = $_POST["sub_level_2_letter_spacing"];
	else $sub_level_2_letter_spacing = "-not selected-";
	if (isset($_POST["sub_level_2_letter_spacing_units"])) $sub_level_2_letter_spacing_units = $_POST["sub_level_2_letter_spacing_units"];
	else $sub_level_2_letter_spacing_units = "-not selected-";	
	if (is_numeric($_POST["sub_level_2_italic"])) $sub_level_2_italic = $_POST["sub_level_2_italic"];
	else $sub_level_2_italic = 0;
	if (is_numeric($_POST["sub_level_2_underline"])) $sub_level_2_underline = $_POST["sub_level_2_underline"];
	else $sub_level_2_underline = 0;
	if (is_numeric($_POST["sub_level_2_overline"])) $sub_level_2_overline = $_POST["sub_level_2_overline"];
	else $sub_level_2_overline = 0;
	if (is_numeric($_POST["sub_level_2_blink"])) $sub_level_2_blink = $_POST["sub_level_2_blink"];
	else $sub_level_2_blink = 0;
	if (is_numeric($_POST["sub_level_2_oblique"])) $sub_level_2_oblique = $_POST["sub_level_2_oblique"];
	else $sub_level_2_oblique = 0;
	if (is_numeric($_POST["sub_level_2_small_caps"])) $sub_level_2_small_caps = $_POST["sub_level_2_small_caps"];
	else $sub_level_2_small_caps = 0;
	if (is_numeric($_POST["sub_level_2_shadow"])) $sub_level_2_shadow = $_POST["sub_level_2_shadow"];
	else $sub_level_2_shadow = 0;
	if (isset($_POST["sub_level_2_shadow_color"])) $sub_level_2_shadow_color = $_POST["sub_level_2_shadow_color"];
	else $sub_level_2_shadow_color = "-not set-";
	if (is_numeric($_POST["sub_level_2_shadow_x_offset"])) $sub_level_2_shadow_x_offset = $_POST["sub_level_2_shadow_x_offset"];
	else $sub_level_2_shadow_x_offset = 0;
	if (is_numeric($_POST["sub_level_2_shadow_y_offset"])) $sub_level_2_shadow_y_offset = $_POST["sub_level_2_shadow_y_offset"];
	else $sub_level_2_shadow_y_offset = 0;
	if (is_numeric($_POST["sub_level_2_shadow_blur"])) $sub_level_2_shadow_blur = $_POST["sub_level_2_shadow_blur"];
	else $sub_level_2_shadow_blur = 0;
	if (isset($_POST["sub_level_2_text_color"])) $sub_level_2_text_color = $_POST["sub_level_2_text_color"];
	else $sub_level_2_text_color = "-not set-";
	
	if (isset($_POST["top_level_text_color_hover"])) $top_level_text_color_hover = $_POST["top_level_text_color_hover"];
	else $top_level_text_color_hover = "-not set-";
	if (isset($_POST["sub_level_1_text_color_hover"])) $sub_level_1_text_color_hover = $_POST["sub_level_1_text_color_hover"];
	else $sub_level_1_text_color_hover = "-not set-";
	if (isset($_POST["sub_level_2_text_color_hover"])) $sub_level_2_text_color_hover = $_POST["sub_level_2_text_color_hover"];
	else $sub_level_2_text_color_hover = "-not set-";
	if (isset($_POST["sub_level_1_text_color_active"])) $sub_level_1_text_color_active = $_POST["sub_level_1_text_color_active"];
	else $sub_level_1_text_color_active = "-not set-";
	
	if (isset($_POST["top_level_background_color"])) $top_level_background_color = $_POST["top_level_background_color"];
	else $top_level_background_color = "-not set-";
	if (isset($_POST["top_level_background_color_hover"])) $top_level_background_color_hover = $_POST["top_level_background_color_hover"];
	else $top_level_background_color_hover = "-not set-";
	if (isset($_POST["top_level_background_color_active"])) $top_level_background_color_active = $_POST["top_level_background_color_active"];
	else $top_level_background_color_active = "-not set-";
	
	if (isset($_POST["sub_level_background_color"])) $sub_level_background_color = $_POST["sub_level_background_color"];
	else $sub_level_background_color = "-not set-";
	
	if (is_numeric($_POST["top_level_block_border_width"])) $top_level_block_border_width = $_POST["top_level_block_border_width"];
	else $top_level_block_border_width = -1;
	if (isset($_POST["top_level_block_border_color"])) $top_level_block_border_color = $_POST["top_level_block_border_color"];
	else $top_level_block_border_color = "-not set-";
	if (is_numeric($_POST["sub_level_block_border_width"])) $sub_level_block_border_width = $_POST["sub_level_block_border_width"];
	else $sub_level_block_border_width = -1;
	if (isset($_POST["sub_level_block_border_color"])) $sub_level_block_border_color = $_POST["sub_level_block_border_color"];
	else $sub_level_block_border_color = "-not set-";
	
	if (is_numeric($_POST["top_level_item_border_width"])) $top_level_item_border_width = $_POST["top_level_item_border_width"];
	else $top_level_item_border_width = -1;
	if (isset($_POST["top_level_item_border_color"])) $top_level_item_border_color = $_POST["top_level_item_border_color"];
	else $top_level_item_border_color = "-not set-";
	if (isset($_POST["top_level_item_border_color_hover"])) $top_level_item_border_color_hover = $_POST["top_level_item_border_color_hover"];
	else $top_level_item_border_color_hover = "-not set-";
	if (isset($_POST["top_level_item_border_color_active"])) $top_level_item_border_color_active = $_POST["top_level_item_border_color_active"];
	else $top_level_item_border_color_active = "-not set-";
	
	if (is_numeric($_POST["sub_level_item_border_width"])) $sub_level_item_border_width = $_POST["sub_level_item_border_width"];
	else $sub_level_item_border_width = -1;
	if (isset($_POST["sub_level_item_border_color"])) $sub_level_item_border_color = $_POST["sub_level_item_border_color"];
	else $sub_level_item_border_color = "-not set-";
	
	if (is_numeric($_POST["top_level_block_border_top"])) $top_level_block_border_top = $_POST["top_level_block_border_top"];
	else $top_level_block_border_top = 0;
	if (is_numeric($_POST["top_level_block_border_bottom"])) $top_level_block_border_bottom = $_POST["top_level_block_border_bottom"];
	else $top_level_block_border_bottom = 0;
	if (is_numeric($_POST["top_level_block_border_left"])) $top_level_block_border_left = $_POST["top_level_block_border_left"];
	else $top_level_block_border_left = 0;
	if (is_numeric($_POST["top_level_block_border_right"])) $top_level_block_border_right = $_POST["top_level_block_border_right"];
	else $top_level_block_border_right = 0;
	$top_level_block_border_sides = ($top_level_block_border_top * 8) | ($top_level_block_border_bottom * 4) | ($top_level_block_border_left * 2) | $top_level_block_border_right;
	
	if (isset($_POST["sub_level_block_border_top"])) $sub_level_block_border_top = $_POST["sub_level_block_border_top"];
	else $sub_level_block_border_top = 0;
	if (isset($_POST["sub_level_block_border_bottom"])) $sub_level_block_border_bottom = $_POST["sub_level_block_border_bottom"];
	else $sub_level_block_border_bottom = 0;
	if (isset($_POST["sub_level_block_border_left"])) $sub_level_block_border_left = $_POST["sub_level_block_border_left"];
	else $sub_level_block_border_left = 0;
	if (isset($_POST["sub_level_block_border_right"])) $sub_level_block_border_right = $_POST["sub_level_block_border_right"];
	else $sub_level_block_border_right = 0;
	$sub_level_block_border_sides = ($sub_level_block_border_top * 8) | ($sub_level_block_border_bottom * 4) | ($sub_level_block_border_left * 2) | $sub_level_block_border_right;
	
	if (isset($_POST["top_level_item_border_top"])) $top_level_item_border_top = $_POST["top_level_item_border_top"];
	else $top_level_item_border_top = 0;
	if (isset($_POST["top_level_item_border_bottom"])) $top_level_item_border_bottom = $_POST["top_level_item_border_bottom"];
	else $top_level_item_border_bottom = 0;
	if (isset($_POST["top_level_item_border_left"])) $top_level_item_border_left = $_POST["top_level_item_border_left"];
	else $top_level_item_border_left = 0;
	if (isset($_POST["top_level_item_border_right"])) $top_level_item_border_right = $_POST["top_level_item_border_right"];
	else $top_level_item_border_right = 0;
	$top_level_item_border_sides = ($top_level_item_border_top * 8) | ($top_level_item_border_bottom * 4) | ($top_level_item_border_left * 2) | $top_level_item_border_right;
	
	if (isset($_POST["sub_level_item_border_top"])) $sub_level_item_border_top = $_POST["sub_level_item_border_top"];
	else $sub_level_item_border_top = 0;
	if (isset($_POST["sub_level_item_border_bottom"])) $sub_level_item_border_bottom = $_POST["sub_level_item_border_bottom"];
	else $sub_level_item_border_bottom = 0;
	if (isset($_POST["sub_level_item_border_left"])) $sub_level_item_border_left = $_POST["sub_level_item_border_left"];
	else $sub_level_item_border_left = 0;
	if (isset($_POST["sub_level_item_border_right"])) $sub_level_item_border_right = $_POST["sub_level_item_border_right"];
	else $sub_level_item_border_right = 0;
	$sub_level_item_border_sides = ($sub_level_item_border_top * 8) | ($sub_level_item_border_bottom * 4) | ($sub_level_item_border_left * 2) | $sub_level_item_border_right;
	
	if (is_numeric($_POST["top_level_background_opacity"])) $top_level_background_opacity = $_POST["top_level_background_opacity"];
	else $top_level_background_opacity = -1;
	if (is_numeric($_POST["sub_level_background_opacity"])) $sub_level_background_opacity = $_POST["sub_level_background_opacity"];
	else $sub_level_background_opacity = -1;
		

	///////////////////////////////////////////////////////////////////////////////////////////
	if (($top_level_underline == 0) && ($top_level_overline == 0) && (top_level_blink == 0))
		$text_decoration_none = 1;
	else
		$text_decoration_none = 0;
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.top_level_a" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, font='" . $top_level_font 
		. "', font_size=" . $top_level_font_size . ", font_size_units='" . $top_level_font_size_units
		. "', weight='" . $top_level_weight . "', letter_spacing='" . $top_level_letter_spacing 
		. "', letter_spacing_units=" . $top_level_letter_spacing_units
		. ", italic=" . $top_level_italic 
		. ", underline=" . $top_level_underline . ", overline=" . $top_level_overline . ", blink=" . $top_level_blink
		. ", oblique=" . $top_level_oblique . ", small_caps=" . $top_level_small_caps . ", no_text_decoration=" . $text_decoration_none
		. ", shadow=" . $top_level_shadow
		. ", shadow_color='" . $top_level_shadow_color . "', shadow_x_offset=" . $top_level_shadow_x_offset
		. ", shadow_y_offset=" . $top_level_shadow_y_offset . ", shadow_blur=" . $top_level_shadow_blur
		. ", text_color='" . $top_level_text_color . "', bkgd_opacity=-1, display='block' WHERE class='.top_level_a" . $suffix . "'";
	}
	else
	{
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.top_level_a" . $suffix . "', use_table_data=1, font='" . $top_level_font
		. "', font_size=" . $top_level_font_size . ", font_size_units='" . $top_level_font_size_units
		. "', weight='" . $top_level_weight . "', letter_spacing='" . $top_level_letter_spacing 
		. "', letter_spacing_units=" . $top_level_letter_spacing_units
		. ", italic=" . $top_level_italic 
		. ", underline=" . $top_level_underline . ", overline=" . $top_level_overline . ", blink=" . $top_level_blink
		. ", oblique=" . $top_level_oblique . ", small_caps=" . $top_level_small_caps . ", no_text_decoration=" . $text_decoration_none
		. ", shadow=" . $top_level_shadow
		. ", shadow_color='" . $top_level_shadow_color . "', shadow_x_offset=" . $top_level_shadow_x_offset
		. ", shadow_y_offset=" . $top_level_shadow_y_offset . ", shadow_blur=" . $top_level_shadow_blur
		. ", text_color='" . $top_level_text_color . "', bkgd_opacity=-1, display='block'";
	}
	$cnt = $bwb_dbh->exec($query);
	
	///////////////////////////////////////////////////////////////////////////////////////////
	if (($sub_level_1_underline == 0) && ($sub_level_1_overline == 0) && (sub_level_1_blink == 0))
		$text_decoration_none = 1;
	else
		$text_decoration_none = 0;
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.sub_level_1_a" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, font='" . $sub_level_1_font 
		. "', font_size=" . $sub_level_1_font_size . ", font_size_units='" . $sub_level_1_font_size_units
		. "', weight='" . $sub_level_1_weight . "', letter_spacing='" . $sub_level_1_letter_spacing 
		. "', letter_spacing_units=" . $sub_level_1_letter_spacing_units
		. ", italic=" . $sub_level_1_italic 
		. ", underline=" . $sub_level_1_underline . ", overline=" . $sub_level_1_overline . ", blink=" . $sub_level_1_blink
		. ", oblique=" . $sub_level_1_oblique . ", small_caps=" . $sub_level_1_small_caps . ", no_text_decoration=" . $text_decoration_none
		. ", shadow=" . $sub_level_1_shadow
		. ", shadow_color='" . $sub_level_1_shadow_color . "', shadow_x_offset=" . $sub_level_1_shadow_x_offset
		. ", shadow_y_offset=" . $sub_level_1_shadow_y_offset . ", shadow_blur=" . $sub_level_1_shadow_blur
		. ", text_color='" . $sub_level_1_text_color . "', bkgd_opacity=-1 WHERE class='.sub_level_1_a" . $suffix . "'";
	}
	else
	{
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.sub_level_1_a" . $suffix . "', use_table_data=1, font='" . $sub_level_1_font
		. "', font_size=" . $sub_level_1_font_size . ", font_size_units='" . $sub_level_1_font_size_units
		. "', weight='" . $sub_level_1_weight . "', letter_spacing='" . $sub_level_1_letter_spacing 
		. "', letter_spacing_units=" . $sub_level_1_letter_spacing_units
		. ", italic=" . $sub_level_1_italic 
		. ", underline=" . $sub_level_1_underline . ", overline=" . $sub_level_1_overline . ", blink=" . $sub_level_1_blink
		. ", oblique=" . $sub_level_1_oblique . ", small_caps=" . $sub_level_1_small_caps . ", no_text_decoration=" . $text_decoration_none
		. ", shadow=" . $sub_level_1_shadow
		. ", shadow_color='" . $sub_level_1_shadow_color . "', shadow_x_offset=" . $sub_level_1_shadow_x_offset
		. ", shadow_y_offset=" . $sub_level_1_shadow_y_offset . ", shadow_blur=" . $sub_level_1_shadow_blur
		. ", text_color='" . $sub_level_1_text_color . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	///////////////////////////////////////////////////////////////////////////////////////////
	if (($sub_level_2_underline == 0) && ($sub_level_2_overline == 0) && (sub_level_2_blink == 0))
		$text_decoration_none = 1;
	else
		$text_decoration_none = 0;
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.sub_level_2_a" . $suffix . "'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, font='" . $sub_level_2_font 
		. "', font_size=" . $sub_level_2_font_size . ", font_size_units='" . $sub_level_2_font_size_units
		. "', weight='" . $sub_level_2_weight . "', letter_spacing='" . $sub_level_2_letter_spacing 
		. "', letter_spacing_units=" . $sub_level_2_letter_spacing_units
		. ", italic=" . $sub_level_2_italic 
		. ", underline=" . $sub_level_2_underline . ", overline=" . $sub_level_2_overline . ", blink=" . $sub_level_2_blink
		. ", oblique=" . $sub_level_2_oblique . ", small_caps=" . $sub_level_2_small_caps . ", no_text_decoration=" . $text_decoration_none
		. ", shadow=" . $sub_level_2_shadow
		. ", shadow_color='" . $sub_level_2_shadow_color . "', shadow_x_offset=" . $sub_level_2_shadow_x_offset
		. ", shadow_y_offset=" . $sub_level_2_shadow_y_offset . ", shadow_blur=" . $sub_level_2_shadow_blur
		. ", text_color='" . $sub_level_2_text_color . "', bkgd_opacity=-1 WHERE class='.sub_level_2_a" . $suffix . "'";
	}
	else
	{
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.sub_level_2_a" . $suffix . "', use_table_data=1, font='" . $sub_level_2_font
		. "', font_size=" . $sub_level_2_font_size . ", font_size_units='" . $sub_level_2_font_size_units
		. "', weight='" . $sub_level_2_weight . "', letter_spacing='" . $sub_level_2_letter_spacing 
		. "', letter_spacing_units=" . $sub_level_2_letter_spacing_units
		. ", italic=" . $sub_level_2_italic 
		. ", underline=" . $sub_level_2_underline . ", overline=" . $sub_level_2_overline . ", blink=" . $sub_level_2_blink
		. ", oblique=" . $sub_level_2_oblique . ", small_caps=" . $sub_level_2_small_caps . ", no_text_decoration=" . $text_decoration_none
		. ", shadow=" . $sub_level_2_shadow
		. ", shadow_color='" . $sub_level_2_shadow_color . "', shadow_x_offset=" . $sub_level_2_shadow_x_offset
		. ", shadow_y_offset=" . $sub_level_2_shadow_y_offset . ", shadow_blur=" . $sub_level_2_shadow_blur
		. ", text_color='" . $sub_level_2_text_color . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = 'ul.nav" . $suffix . ", .nav" . $suffix . " ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, border=" . $top_level_block_border_width . ", border_color='" . $top_level_block_border_color . "', border_sides=" . $top_level_block_border_sides
		. ", bkgd_opacity=-1 WHERE class='ul.nav" . $suffix . ", .nav" . $suffix . " ul'";
	}
	else
	{
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='ul.nav" . $suffix . ", .nav" . $suffix . " ul', use_table_data=1, border=" . $top_level_block_border_width
		. ", border_color='" . $top_level_block_border_color . "', border_sides=" . $top_level_block_border_sides . ", bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = 'ul.nav" . $suffix . ">li'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, bkgd_color='" . $top_level_background_color 
		. "', border=" . $top_level_item_border_width
		. ", border_color='" . $top_level_item_border_color . "', border_sides=" . $top_level_item_border_sides . ", bkgd_opacity=-1 WHERE class='ul.nav" . $suffix . ">li'";
	}
	else
	{
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='ul.nav" . $suffix . ">li', use_table_data=1, bkgd_color='" . $top_level_background_color 
		. "', border=" . $top_level_item_border_width
		. ", border_color='" . $top_level_item_border_color . "', border_sides=" . $top_level_item_border_sides . "', z_index=5, bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = 'ul.nav" . $suffix . " li>ul'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, border=" . $sub_level_block_border_width . ", border_color='" . $sub_level_block_border_color . "', border_sides=" . $sub_level_block_border_sides
		. ", bkgd_opacity=-1 WHERE class='ul.nav" . $suffix . " li>ul'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='ul.nav" . $suffix . " li>ul', use_table_data=1, border=" . $sub_level_block_border_width
		. ", border_color='" . $sub_level_block_border_color . "', border_sides=" . $top_level_block_border_sides . ", bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `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_table . " SET use_table_data=1, border=" . $sub_level_item_border_width . ", border_color='"
		. $sub_level_item_border_color. "', border_sides=" . $sub_level_item_border_sides . ", bkgd_opacity=-1 WHERE class='.nav" . $suffix . " ul li a'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.nav" . $suffix . " ul li a', use_table_data=1, border=" . $sub_level_item_border_width . ", border_color='"
		. $sub_level_item_border_color . "', border_sides=" . $sub_level_item_border_sides . ", bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = 'ul.nav" . $suffix . " li:hover, .nav" . $suffix . " ul li a:hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, bkgd_color='" . $top_level_background_color_hover
		. "', border=" . $top_level_item_border_width . ", border_color='" . $top_level_item_border_color_hover
		. "', border_sides=" . $top_level_item_border_sides
		. ", bkgd_opacity=-1 WHERE class='ul.nav" . $suffix . " li:hover, .nav" . $suffix . " ul li a:hover'";

	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='ul.nav" . $suffix . " li:hover, .nav" . $suffix . " ul li a:hover', use_table_data=1, bkgd_color='" 
		. $top_level_background_color_hover
		. "', border=" . $top_level_item_border_width . ", border_color='" . $top_level_item_border_color_hover
		. "', border_sides=" . $top_level_item_border_sides . ", z_index=10, bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = 'ul.nav" . $suffix . " li:active, .nav" . $suffix . " ul li a:active'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $sub_level_1_text_color_active . "', bkgd_color='" . $top_level_background_color_active
		. "', border=" . $top_level_item_border_width . ", border_color='" . $top_level_item_border_color_active
		. "', border_sides=" . $top_level_item_border_sides
		. ", bkgd_opacity=-1 WHERE class='ul.nav" . $suffix . " li:active, .nav" . $suffix . " ul li a:active'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='ul.nav" . $suffix . " li:active, .nav" . $suffix . " ul li a:active', use_table_data=1, text_color='"
		. $sub_level_1_text_color_active . "', bkgd_color='" . $top_level_background_color_active
		. "', border=" . $top_level_item_border_width . ", border_color='" . $top_level_item_border_color_active
		. "', border_sides=" . $top_level_item_border_sides . ", bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = 'ul.nav" . $suffix . ", .nav" . $suffix . " ul, .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_table . " SET use_table_data=1, bkgd_color='" . $sub_level_background_color
		. "', bkgd_opacity=-1 WHERE class='ul.nav" . $suffix . ", .nav" . $suffix . " ul, .nav" . $suffix . " ul li a'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='ul.nav" . $suffix . ", .nav" . $suffix . " ul, .nav" . $suffix . " ul li a', use_table_data=1, bkgd_color='"
		. $sub_level_background_color . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.top_level_li" . $suffix . " A:hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $top_level_text_color_hover
		. "', bkgd_opacity=-1 WHERE class='.top_level_li" . $suffix . " A:hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.top_level_li" . $suffix . " A:hover', use_table_data=1, text_color='"
		. $top_level_text_color_hover . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// new /////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.top_level_li" . $suffix . " A:visited:hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $top_level_text_color_hover
		. "', bkgd_opacity=-1 WHERE class='.top_level_li" . $suffix . " A:visited:hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.top_level_li" . $suffix . " A:visited:hover', use_table_data=1, text_color='"
		. $top_level_text_color_hover . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.top_level_li" . $suffix . " A:visited'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $top_level_text_color
		. "', bkgd_opacity=-1 WHERE class='.top_level_li" . $suffix . " A:visited'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.top_level_li" . $suffix . " A:visited', use_table_data=1, text_color='" . $top_level_text_color . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// new //////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.sub_level_1_li" . $suffix . " A:hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $sub_level_1_text_color_hover
		. "', bkgd_opacity=-1 WHERE class='.sub_level_1_li" . $suffix . " A:hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.sub_level_1_li" . $suffix . " A:hover', use_table_data=1, text_color='"
		. $sub_level_1_text_color_hover . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// new //////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.sub_level_1_li" . $suffix . " A:visited:hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $sub_level_1_text_color_hover
		. "', bkgd_opacity=-1 WHERE class='.sub_level_1_li" . $suffix . " A:visited:hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.sub_level_1_li" . $suffix . " A:visited:hover', use_table_data=1, text_color='"
		. $sub_level_1_text_color_hover . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.sub_level_1_li" . $suffix . " A:visited'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $sub_level_1_text_color
		. "', bkgd_opacity=-1 WHERE class='.sub_level_1_li" . $suffix . " A:visited'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.sub_level_1_li" . $suffix . " A:visited', use_table_data=1, text_color='" . $sub_level_1_text_color . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// new //////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.sub_level_2_li" . $suffix . " A:hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $sub_level_2_text_color_hover
		. "', bkgd_opacity=-1 WHERE class='.sub_level_2_li" . $suffix . " A:hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.sub_level_2_li" . $suffix . " A:hover', use_table_data=1, text_color='"
		. $sub_level_2_text_color_hover . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	////////////////////////////// new //////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.sub_level_2_li" . $suffix . " A:visited:hover'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $sub_level_2_text_color_hover
		. "', bkgd_opacity=-1 WHERE class='.sub_level_2_li" . $suffix . " A:visited:hover'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.sub_level_2_li" . $suffix . " A:visited:hover', use_table_data=1, text_color='"
		. $sub_level_2_text_color_hover . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.sub_level_2_li" . $suffix . " A:visited'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, text_color='" . $sub_level_2_text_color
		. "', bkgd_opacity=-1 WHERE class='.sub_level_2_li" . $suffix . " A:visited'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.sub_level_2_li" . $suffix . " A:visited', use_table_data=1, text_color='" . $sub_level_2_text_color . "', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.top_level_li" . $suffix . " A'";
	$result = $bwb_dbh->query($query);
	$row_count = $result->rowCount();
	if ($row_count > 0)
	{
		//Update class record.
		$query = "UPDATE " . BWB_TABLE_PREFIX . $site_css_table . " SET use_table_data=1, display='block', bkgd_opacity=-1 WHERE class='.top_level_li" . $suffix . " A'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.top_level_li" . $suffix . " A', use_table_data=1, display='block', bkgd_opacity=-1";
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.top_level_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_table . " SET use_table_data=1, bkgd_opacity=" . $top_level_background_opacity . " WHERE class='.top_level_ul" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.top_level_ul" . $suffix . "', use_table_data=1, bkgd_opacity=" . $top_level_background_opacity;
	}
	$cnt = $bwb_dbh->exec($query);
	
	//////////////////////////////////////////////////////////////////////////////////////////
	$query = "SELECT `use_table_data` FROM " . BWB_TABLE_PREFIX . $site_css_table . " WHERE `class` = '.sub_level_1_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_table . " SET use_table_data=1, bkgd_opacity=" . $sub_level_background_opacity . " WHERE class='.sub_level_1_ul" . $suffix . "'";
	}
	else
	{
		//Insert new data into table.
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . $site_css_table . " SET class='.sub_level_1_ul" . $suffix . "', use_table_data=1, bkgd_opacity=" . $sub_level_background_opacity;
	}
	$cnt = $bwb_dbh->exec($query);
	


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

	////////////////////////////////////////////////////////
	/// 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;
?>
