////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 4/5/2015	ELL

window.parent.document.title = document.title;
	
function SelectMenu(menu)
{
	var url = "edit_js_menu_styles.php?menu=" + menu;
	window.location.href = url;
}

function popupcolorpicker(form_name, field_name)
{
	var start_color = document.getElementById(field_name).value;
	if (start_color == "")
		start_color = "-not set-";
	else
		start_color = start_color.replace("#", "");
	
	var URL = "colorpicker.php?form_name=" + form_name + "&field_name=" + field_name + "&source_page=edit_js_menu_styles.php&start_color=" + start_color;
	
	window.open (URL, "colorpicker", "alwaysRaised=0,dependent=1,menubar=0,resizable=0,width=450,height=350,scrollbars=0,location=0");
}

function enable_disable_shadow(level, mouse_event)
{
	var shadow = level + "_shadow_" + mouse_event;
	var shadow_color = level + "_shadow_color_" + mouse_event;
	var shadow_x_offset = level + "_shadow_x_offset_" + mouse_event;
	var shadow_y_offset = level + "_shadow_y_offset_" + mouse_event;
	var shadow_blur = level + "_shadow_blur_" + mouse_event;
	
	
	if (document.getElementById(shadow).checked == true)
	{
		document.getElementById(shadow_color).disabled = false;
		document.getElementById(shadow_x_offset).disabled = false;
		document.getElementById(shadow_y_offset).disabled = false;
		document.getElementById(shadow_blur).disabled = false;
	}
	else
	{
		document.getElementById(shadow_color).disabled = true;
		document.getElementById(shadow_x_offset).disabled = true;
		document.getElementById(shadow_y_offset).disabled = true;
		document.getElementById(shadow_blur).disabled = true;
	}
}

function enable_disable_controls()
{
	enable_disable_shadow('top_level', 'out');
	enable_disable_shadow('top_level', 'over');
	enable_disable_shadow('sub_level_1', 'out');
	enable_disable_shadow('sub_level_1', 'over');
	enable_disable_shadow('sub_level_2', 'out');
	enable_disable_shadow('sub_level_2', 'over');
	
	enable_disable_font_size('top_level_font_size_out', 'top_level_font_size_units_out');
	enable_disable_font_size('top_level_font_size_over', 'top_level_font_size_units_over');
	enable_disable_font_size('sub_level_1_font_size_out', 'sub_level_1_font_size_units_out');
	enable_disable_font_size('sub_level_1_font_size_over', 'sub_level_1_font_size_units_over');
	enable_disable_font_size('sub_level_2_font_size_out', 'sub_level_2_font_size_units_out');
	enable_disable_font_size('sub_level_2_font_size_over', 'sub_level_2_font_size_units_over');
}

function OpenHelpWindow()
{
	window.open("http://breezewebsitebuilder.com/docs/cms/help.html#edit_menu_styles", "Help", "scrollbars=1,resizable=1,status=0,toolbar=0,menubar=0,location=0,height=700,width=800");
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////
function enable_disable_font_size(font_size_el_id, font_size_units_el_id)
{
	var units = document.getElementById(font_size_units_el_id).value;
	var font_size = "";
	
	var no_length_arr = new Array("xx-small","x-small","small","medium","large","x-large","xx-large","smaller","larger","initial","inherit");
	var integer_length_arr = new Array("px","%");
	
	if (no_length_arr.indexOf(units) > -1)
		document.getElementById(font_size_el_id).disabled = true;
	else
		document.getElementById(font_size_el_id).disabled = false;
		
	if (integer_length_arr.indexOf(units) > -1)	{
		font_size = document.getElementById(font_size_el_id).value;
		var font_size_arr = font_size.split(".");
		document.getElementById(font_size_el_id).value = font_size_arr[0];
	}
}