//create menu_entry object to store the variables for each menu item
// jfu 02/04/2010: if href is Robertson Express Plust, no m_dir prefixed to href

function menu_entry(m_href, m_target, m_text, section, sub_section, page, nest_level)
{
	this.m_href = m_href; //href of the link
	this.m_text = m_text; //text to display in the button
	this.m_target = m_target; //target - _blank, _parent, _self, _top
	this.section = section; //section button belongs to
	this.sub_section = sub_section; //sub section button belongs to
	this.page = page; //page of this button
	this.nest_level = nest_level; //nesting level of this button (what style to apply)
}

//create a multi-dimensional array the javascript way.
var m_menu =
		new Array(    /*new menu_entry(m_href, m_text, section, sub_section, page, nest_level)*/
		new menu_entry("default.aspx", "_self", "Home", "home", "home", "home", 0),
		new menu_entry("about_us/default.aspx", "_self", "About Us", "about_us", "about_us", "about_us", 0),
		/*new menu_entry("about_us/executive_bios.aspx","_self",  "Executive Bios", "about_us", "executive_bios", "executive_bios", 1),		
		new menu_entry("about_us/president.aspx", "_self", "President", "about_us", "executive_bios", "president", 2), ACM4150 - Removed on 09/08/2008
		new menu_entry("about_us/manager_eng_cs.aspx", "_self", "Builder Services Mgr.", "about_us", "executive_bios", "manager_eng_cs", 2),
		new menu_entry("about_us/controller.aspx", "_self", "Controller", "about_us", "executive_bios", "controller", 2),
		new menu_entry("about_us/director_ca.aspx", "_self", "Dir. of Sales, Canada", "about_us", "executive_bios", "director_ca", 2),
		new menu_entry("about_us/director_us.aspx", "_self", "Dir. of Sales, USA", "about_us", "executive_bios", "director_us", 2),
		new menu_entry("about_us/engineering_manager.aspx", "_self", "Engineering Manager-Schedules/Production", "about_us", "executive_bios", "engineering_manager", 2),
		new menu_entry("about_us/engineering_manager_tech.aspx", "_self", "Engineering Manager-Technical", "about_us", "executive_bios", "engineering_manager_tech", 2),
		/*new menu_entry("about_us/manager_of_drafting.aspx", "_self", "Manager of Systems", "about_us", "executive_bios", "manager_of_drafting", 2),
		new menu_entry("about_us/marketing_manager.aspx", "_self", "Marketing Manager", "about_us", "executive_bios", "marketing_manager", 2),
		/*DCM933 - removed on 11/26/2007; ACM4128 - added on 09/04/2008
		new menu_entry("about_us/operations_manager.aspx", "_self", "Operations Manager", "about_us", "executive_bios", "operations_manager", 2),
		DCM1099 - removed on 4/8/2008
		new menu_entry("about_us/plant_manager.aspx", "_self", "Plant Manager", "about_us", "executive_bios", "plant_manager", 2),
		/*new menu_entry("about_us/vp_sales.aspx", "_self", "Vice President of Sales", "about_us", "executive_bios", "vp_sales", 2),*/
		new menu_entry("about_us/our_clients.aspx", "_self", "Our Clients", "about_us", "our_clients", "our_clients", 1),
		/*new menu_entry("about_us/trademark_info.aspx", "_self", "Trademark Info", "about_us", "trademark_info", "trademark_info", 1),*/
		new menu_entry("about_us/testimonials.aspx", "_self", "Testimonials", "about_us", "testimonials", "testimonials", 1),
		new menu_entry("about_us/accreditations.aspx", "_self", "Accreditations", "about_us", "accreditations", "accreditations", 1),
		new menu_entry("about_us/design_tools.aspx", "_self", "Design Tools", "about_us", "design_tools", "design_tools", 1),
		// jfu 04/20/09 add green.html
		new menu_entry("green/green.html", "_blank", "Go Green", "go_green", "go_green", "go_green", 0),
		new menu_entry("about_us/drawings.aspx", "_self", "Standard Drawings", "drawings", "drawings", "drawings", 0),
		new menu_entry("downloads/specifications.pdf", "_blank", "Specifications", "specifications", "specifications", "specifications", 0),
		new menu_entry("buildings_systems/default.aspx", "_self", "Products", "buildings_systems", "buildings_systems", "buildings_systems", 0),
		new menu_entry("buildings_systems/structural_systems.aspx", "_self", "Framing Systems", "buildings_systems", "structural_systems", "structural_systems", 1),
		new menu_entry("buildings_systems/clearspan_frames.aspx", "_self", "Clearspan Frames", "buildings_systems", "structural_systems", "clearspan_frames", 2),
		new menu_entry("buildings_systems/multispan_frames.aspx", "_self", "Multi-span Frames", "buildings_systems", "structural_systems", "multispan_frames", 2),
		new menu_entry("buildings_systems/leanto_frame.aspx", "_self", "Lean-to Frames", "buildings_systems", "structural_systems", "leanto_frames", 2),
		new menu_entry("buildings_systems/sidewallendwall_members.aspx", "_self", "Sidewall/Endwall Members", "buildings_systems", "structural_systems", "sidewallendwall_members", 2),
		new menu_entry("buildings_systems/roofeave_members.aspx", "_self", "Roof/Eave Members", "buildings_systems", "structural_systems", "roofeave_members", 2),
		new menu_entry("buildings_systems/bracing.aspx", "_self", "Bracing", "buildings_systems", "bracing", "bracing", 1),
		new menu_entry("buildings_systems/wall_panel.aspx", "_self", "Wall Panels", "buildings_systems", "wall_panel", "wall_panel", 1),
		new menu_entry("buildings_systems/a_36.aspx", "_self", "A-36", "buildings_systems", "wall_panel", "a_36", 2),
		new menu_entry("buildings_systems/dura_rib.aspx", "_self", "Dura-Rib", "buildings_systems", "wall_panel", "dura_rib", 2),
		new menu_entry("buildings_systems/aw_200.aspx", "_self", "AW-200", "buildings_systems", "wall_panel", "aw_200", 2),
		new menu_entry("buildings_systems/aw_300.aspx", "_self", "AW-300", "buildings_systems", "wall_panel", "aw_300", 2),
		new menu_entry("buildings_systems/strukturoc.aspx", "_self", "Strukturoc", "buildings_systems", "wall_panel", "strukturoc", 2),
		new menu_entry("buildings_systems/cfw_ii.aspx", "_self", "ShadowRib", "buildings_systems", "wall_panel", "cfw_ii", 2),
		new menu_entry("buildings_systems/rts_wall.aspx", "_self", "RTS", "buildings_systems", "wall_panel", "rts", 2),
		new menu_entry("buildings_systems/roof_panel.aspx", "_self", "Roof Panels", "buildings_systems", "roof_panel", "roof_panel", 1),
		new menu_entry("buildings_systems/seamed_roof_panel_ssr.aspx", "_self", "SSR Standing Seam", "buildings_systems", "roof_panel", "seamed_roof_panel_ssr", 2),
		new menu_entry("buildings_systems/seamed_roof_panel_asr.aspx", "_self", "BattenLok HS", "buildings_systems", "roof_panel", "seamed_roof_panel_asr", 2),
		new menu_entry("buildings_systems/dura_rib_trhough_fastened.aspx", "_self", "Dura-Rib Through Fastened", "buildings_systems", "roof_panel", "dura_rib_through_fastened", 2),
		new menu_entry("buildings_systems/hr_900.aspx", "_self", "HR-900", "buildings_systems", "roof_panel", "hr_900", 2),
		new menu_entry("buildings_systems/rts_roof.aspx", "_self", "RTS", "buildings_systems", "roof_panel", "rts", 2),
		//new menu_entry("buildings_systems/accesories.aspx", "_self", "Accessories", "buildings_systems", "accesories", "accesories", 1),
		new menu_entry("buildings_systems/windows.aspx", "_self", "Windows", "buildings_systems", "accesories", "windows", 2),
		new menu_entry("buildings_systems/doors.aspx", "_self", "Doors", "buildings_systems", "accesories", "doors", 2),
		new menu_entry("buildings_systems/louvers.aspx", "_self", "Louvers", "buildings_systems", "accesories", "louvers", 2),
		new menu_entry("buildings_systems/trim_flashing.aspx", "_self", "Trim and Flashing", "buildings_systems", "accesories", "trim_flashing", 2),
		new menu_entry("buildings_systems/rooftop_units.aspx", "_self", "Rooftop Units", "buildings_systems", "accesories", "rooftop_units", 2),
		new menu_entry("buildings_systems/translucent_panels.aspx", "_self", "Translucent Panels", "buildings_systems", "accesories", "translucent_panels", 2),
		new menu_entry("builder_search/find_a_builder.aspx", "_self", "Find A Builder", "find_a_builder", "find_a_builder", "find_a_builder", 0),
		/* jfu 10/29/2009: removed 
		new menu_entry("builder_search/canada.aspx", "_self", "Canada", "find_a_builder", "find_a_builder", "canada", 2),
		new menu_entry("builder_search/united_states.aspx", "_self", "United States", "find_a_builder", "find_a_builder", "united_states", 2),
		new menu_entry("builder_search/international.aspx", "_self", "International", "find_a_builder", "find_a_builder", "international", 2),
		*/
		new menu_entry("showroom/default.aspx", "_self", "Photo Gallery", "showroom", "showroom", "showroom", 0),
		new menu_entry("showroom/showroom.aspx?cid=1", "_self", "Auto Dealerships", "showroom", "showroom", "auto_dealerships", 2),
		new menu_entry("showroom/showroom.aspx?cid=2", "_self", "Aviation", "showroom", "showroom", "aviation", 2),
		new menu_entry("showroom/showroom.aspx?cid=9", "_self", "Distribution Centers", "showroom", "showroom", "distribution", 2),
		new menu_entry("showroom/showroom.aspx?cid=3", "_self", "Government", "showroom", "showroom", "government", 2),
		new menu_entry("showroom/showroom.aspx?cid=4", "_self", "Industrial", "showroom", "showroom", "industrial", 2),
		new menu_entry("showroom/showroom.aspx?cid=5", "_self", "Office & Commercial", "showroom", "showroom", "office_commercial", 2),
		new menu_entry("showroom/showroom.aspx?cid=6", "_self", "Recreation", "showroom", "showroom", "recreation", 2),
		new menu_entry("showroom/showroom.aspx?cid=7", "_self", "Worship Facilities", "showroom", "showroom", "religious_facilities", 2),
		new menu_entry("showroom/showroom.aspx?cid=8", "_self", "Retail", "showroom", "showroom", "retail", 2),
		new menu_entry("downloads/default.aspx", "_self", "Literature", "literature", "literature", "literature", 0),
		new menu_entry("downloads/a-36_wall_panel_system.pdf", "_blank", "A-36 Wall Panel", "literature", "literature", "", 2),
		new menu_entry("downloads/dura-rib_roof_system.pdf", "_blank", "Dura-Rib Roof System", "literature", "literature", "", 2),
		new menu_entry("downloads/dura-rib_wall_system.pdf", "_blank", "Dura-Rib Wall System", "literature", "literature", "", 2),
		new menu_entry("downloads/ssr_standing_seam_roof.pdf", "_blank", "Standing Seam Roof", "literature", "literature", "", 2),
		new menu_entry("downloads/ssr_roof_system.pdf", "_blank", "SSR Roof System", "literature", "literature", "", 2),
		new menu_entry("downloads/color_chart.pdf", "_blank", "Color Chart", "literature", "literature", "", 2),
		new menu_entry("downloads/worship_facilities.pdf", "_blank", "Worship Facilities", "literature", "literature", "", 2),/*ACM1477 - added on 9/10/2008 */
		new menu_entry("downloads/warehouses.pdf", "_blank", "Warehouses", "literature", "literature", "", 2),/*ACM1477 - added on 9/10/2008 */
		new menu_entry("downloads/recreation_facilities.pdf", "_blank", "Recreation Facilities", "literature", "literature", "", 2),/*ACM1477 - added on 9/10/2008 */
		new menu_entry("downloads/products_services.pdf", "_blank", "Products and Services", "literature", "literature", "", 2),/*ACM1477 - added on 9/10/2008 */
		new menu_entry("downloads/long_bays.pdf", "_blank", "Long Bay System", "literature", "literature", "", 2),/*ACM1477 - added on 9/10/2008 */
		new menu_entry("downloads/dealerships.pdf", "_blank", "Dealerships", "literature", "literature", "", 2),/*ACM1477 - added on 9/10/2008 */
		new menu_entry("downloads/basic_buildings.pdf", "_blank", "Basic Buildings", "literature", "literature", "", 2),/*ACM1477 - added on 9/10/2008 */
		new menu_entry("news/default.aspx", "_self", "News", "news", "news", "news", 0),
		//new menu_entry("news/current.aspx", "_self", "Current", "news", "news", "current", 2),
		//new menu_entry("news/archive.aspx", "_self", "Archive", "news", "news", "archive", 2),
		//new menu_entry("jobs/default.aspx", "_self", "Jobs", "jobs", "jobs", "jobs",	0),
		new menu_entry("jobs/join_robertson.aspx", "_self", "Careers", "careers", "careers", "careers", 0),
		new menu_entry("jobs/become_a_builder.aspx", "_self", "Become a Builder", "become_a_builder", "become_a_builder", "become_a_builder", 0),
		//new menu_entry("locations/default.aspx", "_self", "Locations", "locations", "locations", "locations", 0),
		//new menu_entry("locations/head_office.aspx", "_self", "Head Office", "locations", "locations", "head_office", 2),
		//new menu_entry("locations/sales_offices.aspx", "_self", "Sales Offices", "locations", "locations", "sales_offices", 2),
		new menu_entry("contact_us/default.aspx", "_self", "Contact Us", "contact_us", "contact_us", "contact_us", 0),
		// jfu added on 12/10/2009
		new menu_entry("http://buildertracking.ncilp.com/webtracking/login.jsp?selling_div=17&from=rcc", "_blank", "Robertson ExpressPlus", "Robertson_ExpressPlus", "Robertson_ExpressPlus", "Robertson_ExpressPlus", 0)
		);
		
//menu length
var m_menu_length = 0;	
for (m_ref_id in m_menu)
{
	++m_menu_length;
}

function generate_menu(curr_dir)
{
	//if the link is undefined set it to empty so we don't get links concatenated like 'undefineddefault.aspx'
	(curr_dir == undefined) ? curr_dir = '': curr_dir = curr_dir;
	
	//get a reference to our menu div
	var menu_wrapper = document.getElementById("menu");
	
	//for each item in the menu array above
	for (i=0;i < m_menu_length;i++)
	{
		//create an empty div
		menu_item = document.createElement("DIV");
		
		//if the displayed text of the link is longer than ~23 chars apply the '_wrap' version of the style
		//this style of conditional is read as (condition?) ? true then : false then
		(m_menu[i].m_text.length > 23) ? wrap = '_wrap' : wrap = '';
		
		//mark the button that this page belongs to
		(m_menu[i].page == page) ? selected = '_selected' : selected = '';

		//level 0 menu items. dark blue
		//these never get the triangle image
		if ((m_menu[i].nest_level == 0) && !(m_menu[i].section == section))
		{
			
			generate_menu_item(m_menu[i].m_href, m_menu[i].m_target, m_menu[i].m_text, "menu_level_1"+wrap, curr_dir);
		}

		//level 0 menu items selected. light blue
		if (((m_menu[i].nest_level == 0) && (m_menu[i].section == section)) || ((m_menu[i].nest_level == 1) && (m_menu[i].section == section)) && !((m_menu[i].nest_level == 1) && (m_menu[i].section == section) && (m_menu[i].sub_section == sub_section)))
		{
			//if m_menu[i].page == page then use style with 'selected' triangle image
			if (selected)
			{
				generate_menu_item(m_menu[i].m_href, m_menu[i].m_target, m_menu[i].m_text, "menu_level_2"+wrap+selected, curr_dir);
			} else {
				generate_menu_item(m_menu[i].m_href, m_menu[i].m_target, m_menu[i].m_text, "menu_level_2"+wrap, curr_dir);
			}
		}
		
		//level 1 menu items. sage background, bold type.
		if ((m_menu[i].nest_level == 1) && (m_menu[i].section == section) && (m_menu[i].sub_section == sub_section))
		{
			//if m_menu[i].page == page then use style with 'selected' triangle image
			if (selected)
			{
				generate_menu_item(m_menu[i].m_href, m_menu[i].m_target, m_menu[i].m_text, "menu_level_3"+wrap+selected, curr_dir);
			} else {
				generate_menu_item(m_menu[i].m_href, m_menu[i].m_target, m_menu[i].m_text, "menu_level_3"+wrap, curr_dir);
			}
		}
		
		//level 2 menu items. sage background, normal type.
		if ((m_menu[i].nest_level == 2) && (m_menu[i].section == section) && (m_menu[i].sub_section == sub_section) && !(m_menu[i].page == page))
		{
			generate_menu_item(m_menu[i].m_href, m_menu[i].m_target, m_menu[i].m_text, "menu_level_4"+wrap, curr_dir);		
		}		

		//level 2 menu items. white background, black text.
		if ((m_menu[i].nest_level == 2) && (m_menu[i].section == section) && (m_menu[i].sub_section == sub_section) && (m_menu[i].page == page))
		{
			generate_menu_item(m_menu[i].m_href, m_menu[i].m_target, m_menu[i].m_text, "menu_level_5"+wrap, curr_dir);		
		}		
	}

	//generate the menu item and append it to the menu div
	// jfu 02/04/2010: if href is Robertson Express Plust, no m_dir prefixed to href
	function generate_menu_item(m_href, m_target, m_text, m_class, m_dir)
	{
		//create the <a> element for the text link in the menu
		menu_item_a = document.createElement("a");
		
		
		//set <a> href attribute to m_dir + m_href
		if (m_text == 'Robertson ExpressPlus')
		{
			menu_item_a.setAttribute("href", m_href);
		}
		else
			menu_item_a.setAttribute("href", m_dir + m_href);
		menu_item_a.setAttribute("target", m_target);
		
		//create text node for <a> text
		menu_text = document.createTextNode(m_text);
		menu_item_a.setAttribute("title", m_text);
		//assign styles
		menu_item.className = m_class;
		//append text to <a>
		menu_item_a.appendChild(menu_text);
		//append <a> to current div
		menu_item.appendChild(menu_item_a);
		//append current div to menu div
		menu_wrapper.appendChild(menu_item);
	}
	
}

function openWin()
{
	var my_window = window.open('panel_colour_choices.aspx','','scrollbars=0,menubar=0,height=400,width=570,resizable=1,toolbar=0,location=0,status=0');
}