var interval = 0;

function Menu(lpos, rpos, value, ref, width, height, visibility, fontsize)
{
	this.id			= lpos + rpos;
	this.lpos		= lpos;
	this.rpos		= rpos;
	this.value		= value
	this.ref		= ref;
	this.width		= width;
	this.height		= height;
	this.left		= 0;
	this.top		= 0;
	this.visibility	= visibility;
	this.level		= lpos.length;
	this.fontsize	= fontsize;
}

aMenu = new Array();
//constructor
//menu = new Menu('key1', 'key2', 'value', 'target', 'length', 'height', 'visibility: 1=visible; 0=hidden')
//Parent menu must be declared visible - 1

//menu - level 0
aMenu[0] = new Menu('0', '0', 'Home', 'http://www.videoviolinlessons.com', 155, 87, 1, 24);
  //submenu1 - level 0
  aMenu[6] = new Menu('00', '0', 'Welcome', 'http://www.videoviolinlessons.com/index.htm', 135, 35, 0, 16);
  aMenu[7] = new Menu('00', '1', 'Points of Distinction', 'http://www.videoviolinlessons.com/SubPages/AMPPointsDistinct_NM.htm', 135, 35, 0, 16);
aMenu[1] = new Menu('0', '1', 'DVD Lessons', '#', 155, 87, 1, 24);
  //submenu1 - level 1
  aMenu[8] = new Menu('01', '0', 'Lesson Catalog', 'http://www.videoviolinlessons.com/SubPages/AMPLessonCatalog_NM.htm', 135, 35, 0, 16);
  aMenu[9] = new Menu('01', '1', 'Beginner Series', 'http://www.videoviolinlessons.com/SubPages/LessonCatalog/AMPBeginnerSeriesInfo_NM.htm', 135, 35, 0, 16);
  aMenu[10] = new Menu('01', '2', 'Intermediate Series', 'http://www.videoviolinlessons.com/SubPages/LessonCatalog/AMPIntermediateSeriesInfo.htm', 135, 35, 0, 16);
  aMenu[11] = new Menu('01', '3', 'Holiday Series', 'http://www.videoviolinlessons.com/SubPages/LessonCatalog/AMPHolidaySeriesInfo_NM.htm', 135, 35, 0, 16);
  aMenu[12] = new Menu('01', '4', 'Sample Video', 'http://www.videoviolinlessons.com/MainPage/AMPSampleVideo_NM.htm', 135, 35, 0, 16);
  aMenu[13] = new Menu('01', '5', 'Customer Comments', 'http://www.videoviolinlessons.com/SubPages/AMPCustomerComments_NM.htm', 135, 35, 0, 16);
aMenu[2] = new Menu('0', '2', 'About Us', '#', 155, 87, 1, 24);
  //submenu1 - level 2
  aMenu[14] = new Menu('02', '0', 'Mrs. Seidel', 'http://www.videoviolinlessons.com/SubPages/AMPMrsSeidel_NM.htm', 135, 35, 0, 16);
  aMenu[15] = new Menu('02', '1', 'Academy of Music Performance', 'http://www.videoviolinlessons.com/SubPages/AMPAcademy_NM.htm', 135, 35, 0, 16);
aMenu[3] = new Menu('0', '3', 'Ordering DVDs', '#', 155, 87, 1, 24);
  //submenu1 - level 3
  aMenu[16] = new Menu('03', '0', 'Order DVD Lessons', 'http://www.videoviolinlessons.com/SubPages/AMPLessonOrder_NM.htm', 135, 35, 0, 16);
  aMenu[17] = new Menu('03', '1', 'Three Easy Steps', 'http://www.videoviolinlessons.com/SubPages/AMPThreeEasySteps_NM.htm', 135, 35, 0, 16);
  aMenu[18] = new Menu('03', '2', 'Starting Materials', 'http://www.videoviolinlessons.com/SubPages/AMPStartingMaterials_NM.htm', 135, 35, 0, 16);
  aMenu[19] = new Menu('03', '3', 'Common Questions', 'http://www.videoviolinlessons.com/SubPages/AMPCommonQuestions_NM.htm', 135, 35, 0, 16);
aMenu[4] = new Menu('0', '4', 'Contact', '#', 155, 87, 1, 24);
  //submenu1 - level 4
  aMenu[20] = new Menu('04', '0', 'E-mail Mrs. Seidel', 'http://www.videoviolinlessons.com/SubPages/AMPContact_NM.htm', 135, 35, 0, 16);
aMenu[5] = new Menu('0', '5', 'BCS String Quartet', 'http://www.videoviolinlessons.com/BCS/BCSMain.htm', 155, 87, 1, 18);

function hideAll(Object)
{
	for (var i = 1; i < aMenu.length; i++)
	{
		if (aMenu[i].lpos != '0')
			document.getElementById(aMenu[i].id).style.visibility = 'hidden';
	}
}

function showMenus(Object)
{
	for (var i = 0; i < aMenu.length; i++)
	{
		if (aMenu[i].id == Object.id) // find menu
		{
			for (var j = i; j < aMenu.length; j ++)
			{
				if (aMenu[j].lpos == aMenu[i].id) // find submenu 
				{
					document.getElementById(aMenu[j].id).style.visibility = 'visible';
				}
				else // hide rest
				{
					if ((aMenu[j].lpos != '0') && (aMenu[j].level >= aMenu[i].level + 1))
					{
						document.getElementById(aMenu[j].id).style.visibility = 'hidden';
					}
				}
			}
		}
	}
}

function finterval()
{
	interval = setInterval('hideAll(Object)', 500);
}

function shadowMenu(Object)
{
	for (var i = 0; i < aMenu.length; i++)
	{
		if (aMenu[i].id == Object.id)
			document.getElementById(aMenu[i].id).style.background = 'Transparent';
	}
	clearInterval(interval);
}

function unshadowMenu(Object)
{
	for (var i = 0; i < aMenu.length; i++)
	{
		if (aMenu[i].id == Object.id)
			document.getElementById(aMenu[i].id).style.background = 'Transparent';
	}
	finterval();
}

function writeMenu(Menu)
{
	this.background_color	= 'background-color: Transparent;';
	this.margin_bottom		= 'margin-bottom: 1px;';
	this.border_width		= 'border-width: none;';
	this.border_style		= 'border-style: none;';
	this.color				= 'color: #FFFFFF;';
	this.vwidth				= 'width:'	+ Menu.width.toString() + 'px;';
	this.vheight			= 'height:'	+ Menu.height.toString() + 'px;';
	this.font_family		= 'font-family:CommercialScript BT;';
	this.font_size			= 'font-size:' + Menu.fontsize.toString() + 'px;';
	this.font_weight		= 'font-weight:none;';
	this.text_decoration	= 'text-decoration:none;';
	this.text_align			= 'text-align:left;';
	this.text_indent		= 'text-indent: 2px;';
	this.text_shadow		= 'text-shadow:#CC0033;';
	this.vleft				= 'left: ' + Menu.left.toString() + 'px;';
	this.vtop				= 'top: ' + Menu.top.toString() + 'px;';

	if (Menu.visibility == 0)
		this.vvisibility			= 'visibility: hidden;';
	else 
		this.vvisibility			= 'visibility: visible;';

	this.strMenu	= '<A ' + 'HREF="' + Menu.ref + '"' + 'TARGET="_self"'
					+ 'ID="' + Menu.id + '"' + 'VALUE="' + Menu.value + '"'
					+ 'onClick="hideAll(this)"'
					+ 'onMouseOver="showMenus(this); shadowMenu(this)"'
					+ 'onMouseLeave="unshadowMenu(this)"'
					+ 'style="' + this.background_color + this.margin_bottom + this.border_width
					+ this.border_style + this.color + this.vwidth
					+ this.vheight + this.font_family + this.font_size
					+ this.font_weight + this.text_decoration + this.text_align + this.text_indent
					+ this.vvisibility + this.vleft + this.vtop
					+ 'position: absolute;' + this.text_shadow + '">'
					+ Menu.value + '</A>';

	document.write(this.strMenu);
}

function genMenu(aMenu)
{
	aMenu[0].left = 90; // left position
	aMenu[0].top = 155; // top position
	
	writeMenu(aMenu[0]);
	
	for (var i = 1; i < aMenu.length; i++)
	{
		if (aMenu[i].lpos == aMenu[i - 1].lpos) // same menu
		{
			aMenu[i].left = aMenu[i - 1].left;
			aMenu[i].top = aMenu[i - 1].top + aMenu[i - 1].height;
			writeMenu(aMenu[i]);
		}
		for (var k = 0; k < i; k++)
		{
			if ((aMenu[i].lpos == (aMenu[k].lpos + aMenu[k].rpos)) && (aMenu[i].lpos != aMenu[i - 1].lpos)) // find submenu
			{
				aMenu[i].left = aMenu[k].left + aMenu[k].width;
				aMenu[i].top = aMenu[k].top;
				writeMenu(aMenu[i]);
			}
		}
	}
}

genMenu(aMenu);



