// JavaScript Document
function MenuItem( topText, bottomText, tip, url ){
	this.topText = topText;
	this.bottomText = bottomText;
	this.tip = tip;
	this.url = url;

	return this;
}

// Links used on the Welcome page (and possibly elsewhere
fbe = new MenuItem( // Full text link to the Electric home page
	"Fenton Brothers' Electric",
	"Fenton Brothers' Electric",
	'Visit the Fenton Electric home page',
	'electric.htm'
);

about = new MenuItem(
	'About',
	'About Us',
	'About Us',
	'about.htm'
);

locate = new MenuItem(
	'Find Us',
	'Find Us',
	'Get directions to our store',
	'find.htm'
);

contact = new MenuItem(
	'Contact Us',
	'Contact Us',
	'Call or Email',
	'contact.htm'
);

hours = new MenuItem(
	'Hours',
	'Hours of Operation',
	'Stop By',
	'hours.htm'
);

ffl = new MenuItem( // Full text link to the Lighting home page
	"Fenton's Festival of Lights",
	"Fenton's Festival of Lights",
	'Visit Festival Showroom home page',
	'lights.htm'
);

//Links used on the Electric pages and possibly elsewhere
eHome = new MenuItem( // Short text link to the Electric home page
	'Home',
	"Fenton Brothers' Electric",
	'Return to the Fenton Electric home page',
	'electric.htm'
);

staff = new MenuItem(
	'Staff',
	'Our Staff',
	'Meet the staff',
	'staff.htm'
);

commercial = new MenuItem(
	'Commercial',
	'Commercial &amp; Repair',
	'Commercial & Repair',
	'commercial.htm'
);

tools = new MenuItem(
	'Tools',
	'Tools &amp; Supplies',
	'Tools & Supplies',
	'tools.htm'
);

vendors = new MenuItem(
	'Vendors',
	'Vendors',
	'Vendors',
	'vendors.htm'
);

lHome = new MenuItem( // Short text link to the lighting home page
	'Home',
	'Fenton\'s Festival of Lights',
	'Return to the Festival Showroom home page',
	'lights.htm'
);

showroom = new MenuItem(
	'Showroom',
	'Showroom',
	'Showroom',
	'showroom.htm'
);

mainMenuTop = [
	fbe,
	about,
	locate,
	hours,
	contact,
	ffl
];

eMenuTop = [
	eHome,
	staff,
	commercial,
	tools,
	vendors,
	about,
	hours,
	contact,
	locate
];

eMenuBottom = [
	eHome,
	staff,
	commercial,
	tools,
	ffl,
	vendors,
	about,
	hours,
	contact,
	locate
];

lMenuTop = [
	lHome,
	staff,
	showroom,
	vendors,
	about,
	hours,
	contact,
	locate
];

lMenuBottom = [
	lHome,
	staff,
	showroom,
	vendors,
	fbe,
	about,
	hours,
	contact,
	locate
];

function topMenu( arr, side ){
	for( i = 0; i < arr.length; i++ ){
		var lnk = document.createElement( 'a' );
		lnk.setAttribute( 'href', arr[i].url + '?' + side );
		lnk.setAttribute( 'title', arr[i].tip );
		if( arr[i].url == page ) lnk.setAttribute( 'class', 'active' );
		else if(( arr[i].url === 'showroom.htm' ) && (( page === 'diane.htm' ) || ( page === 'artPrints.htm' ) || ( page === 'howardMiller.htm' ))) lnk.setAttribute( 'class', 'active' );
		var txt = document.createTextNode( arr[i].topText );
		lnk.appendChild( txt );
		menuTop.appendChild( lnk );
	}
}

function bottomMenu( arr, side ){
	var this_menu = '';
	var menu_lvl = 1;
	var menu_pos = 0;
	var restart = false;
	for( m = 0 ; m < arr.length ; m++ ){
		if( arr[m]['bottom'] == 0 ) continue;
		if(( menu_pos > 0 ) && ( ( menu_pos % 5 ) != 0 ) && ( menu_lvl == 1 )) this_menu += ' &nbsp; &mdash; &nbsp; ';
		if(( menu_pos > 0 ) && ( ( menu_pos % 6 ) != 0 ) && ( menu_lvl > 1 )) this_menu += ' &nbsp; &mdash; &nbsp; ';
		if((( menu_pos % 5 ) == 0 ) && ( menu_lvl < 2 ) && ( menu_pos > 0 )){
			this_menu += '<br>';
			menu_lvl++;
			restart = true;
		}
		else if((( menu_pos % 6 ) == 0 ) && ( menu_pos > 0 ) && ( menu_lvl >= 2 )  && ( use_arr != menu_main )){
			this_menu += '<br>';
			menu_lvl++;
			restart = true;
		}
		if( restart ){
			menu_pos = 0;
			restart = false;
		}
		if( arr == mainMenuTop ) current_side = 'all';
		if( arr == eMenuBottom ) current_side = 'electric';
		if ( arr == lMenuBottom ) current_side = 'festival';
		
		this_menu += '<a href="' + arr[m].url + '">' + arr[m].bottomText + '</a>';
		menu_pos++;
	}
	if( current_side === 'festival' ) var fb = 'http://www.facebook.com/pages/Fentons-Festival-of-Lights/134614016603623';
	if( current_side === 'electric' ) var fb = 'http://www.facebook.com/pages/Fenton-Bros-Electric/190291954334653';
	if(( current_side === 'festival' ) || ( current_side === 'electric' )) this_menu += '<br><a href="' + fb + '" title="Follow Us on Facebook">Follow Us on Facebook</a>';
	
	// Now we'll add our credit card policy:
	credit = '<br><br>~ ';
	if( shop === 'amps' ) credit += "Fenton Brothers' Electric is";
	else if( shop === 'watts' ) credit += "Fenton's Festival of Lights is";
	else credit += 'Both stores are ';
	credit += ' pleased to accept MasterCard, Visa, Discover &amp; American Express ~';

	// We're also going to put in the appropriate copyright message here:
	copy = '<br><br>&copy;1999 - 2008, 2009, 2011, ';
	store = '';
	if(( current_side == 'all' ) || ( current_side == 'electric' )) store += "Fenton Brothers' Electric";
	if( current_side == 'all' ) store += ' &amp; ';
	if(( current_side == 'all' ) || ( current_side == 'festival' )) store += "Fenton's Festival of Lights";
	copy += store + '<br>235 Ray Avenue NE, New Philadelphia, OH 44663<br>330.343.8858 &nbsp; &mdash; &nbsp; Fax 330.343.6874 &nbsp; &mdash; &nbsp; Toll Free 800.229.8858<br><br>This site best viewed at 1024 x 768 resolution.<br><br><a href="http://DonB.US" title="This site designed by Twisted Gemini Web Solutions"><img src="img/logos/twisted.png" alt="Don Blackwell Digital Developements logo" title="This site designed and maintained by Don Blackwell. Get your site at http://www.donb.us" style="border: 0px; height: 40px; width: 300px; margin: 10px; "><br><a href="http://www.icra.org" title="Labeled with ICRA" target="otherwin"><img src="img/logos/icra.gif" width="40" height="38" alt="Labeled with ICRA" border="0" hspace="5"></a>';
	document.getElementById('bottom_menu_block').innerHTML = this_menu + credit + copy;
	jumpgate();
}

var options = [
	{ 
		action : false,
		title : '',
		url : ''
	},
	{
		action : true,
		title : 'Welcome Page',
		url : 'index.htm?'
	},
	{
		action : true,
		title : 'About Us',
		url : 'about.htm?'
	},
	{
		action : true,
		title : 'Contact Us',
		url : 'contact.htm?'
	},
	{
		action : true,
		title : 'Find Us',
		url : 'find.htm?'
	}
];

function jumpgate(){
	
	var n = 5;

	if(( shop === 'watts' ) || ( shop === 'amps' )) doFB = true;	
	if( shop === 'watts' ){
		var facebook = '<section id="fbLike"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FFentons-Festival-of-Lights%2F134614016603623&amp;send=false&amp;layout=standard&amp;width=375&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:375px; height:25px; position: relative; top: 2px; padding-left: .25em; padding-top: .05em;" allowTransparency="true"></iframe></section>';
	} else if( shop === 'amps' ){
		var facebook = '<section id="fbLike"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FFenton-Bros-Electric%2F190291954334653&amp;send=false&amp;layout=standard&amp;width=375&amp;show_faces=false&amp;action=Like&amp;colorscheme=light&amp;font&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:375px; height:25px; position: relative; top: 2px; padding-left: .25em; padding-top: .05em;" allowTransparency="true"></iframe></section>';
	}
	if( doFB ){
		document.getElementById( 'bottom_spacer' ).innerHTML = facebook;
	}
	
	var choices = '<option>Choose a page</option>';
	choices += '<option class="opt">Welcome Page</option>';
	choices += '<option class="opt">About Us</option>';
	choices += '<option class="opt">Contact Us</option>';
	choices += '<option class="opt">Find Us</option>';
	choices += '<optgroup label="Fenton Brothers\'s Electric">';
	
	for( o = 0; o < eMenuBottom.length; o++ ){
		cur_item = eMenuBottom[o];
		if(( cur_item.url === 'lights.htm' ) || ( cur_item.url === 'contact.htm' ) || ( cur_item.url === 'find.htm' ) || ( cur_item.url === 'about.htm' )) continue;
		options[n] = {
			action : true,
			title : ( cur_item.url === 'electric.htm' ) ? 'Home' : cur_item.bottomText,
			url : cur_item.url + '?electric'
		};
		choices += '<option>' + options[n].title + '</option>';
		n++;
	}
	
	choices += '</optgroup><optgroup label="Fenton\'s Festival of Lights">';
	for( p = 0 ; p < lMenuBottom.length ; p++ ){
		cur_item = lMenuBottom[p];
		if(( cur_item.url === 'electric.htm' ) || ( cur_item.url === 'contact.htm' ) || ( cur_item.url === 'find.htm' ) || ( cur_item.url === 'about.htm' )) continue;
		options[n] = {
			action : true,
			title : (( cur_item.url === 'lights.htm' ) ? 'Home' : cur_item.bottomText ),
		 	url : cur_item.url + '?watts'
		};
		choices += '<option>' + options[n]['title'] + '</option>';
		n++;
	}
	
	choices += '</optgroup>';
	
	choice_list = '<form name="jumper" id="jumper"><select name="jumpTo" id="jumpTo">' + choices + '</select></form>';
	document.getElementById('bottom_spacer').innerHTML += choice_list;
}

function doJump(){
	opt_nbr = document.jumper.jumpTo.selectedIndex;
	if( options[opt_nbr]['action'] == true ) location = options[opt_nbr]['url'];
}

