
var sections;
var menuStyles;

function menuStyle(tableStyle, currentItem, otherItems)
{
	this.tableStyle = tableStyle;
	this.currentItem = currentItem;
	this.otherItems = otherItems;
}

var mainSectionStyle = new menuStyle(new String("tblSections"), new String("tdCurrentSection"), new String("tdSection"));
var subSectionStyle = new menuStyle(new String("tblSubSections"), new String("tdCurrentSubSection"), new String("tdSubSection"));
menuStyles = new Array(mainSectionStyle, subSectionStyle);


function menuItem(caption, link, number, subSections)
{
	this.caption = caption;
	this.link = link;
	this.number = number;
	this.subSections = subSections;
	
	this.write = function()
	{
		return 0;
	}
	
	this.setSubSections = function(sub_sections)
	{
		this.subSections = sub_sections;
	}

	this.getSubSections = function()
	{
		return this.subSections;
	}
	
}

var tempItem01;
var tempItem02;
var tempItem03;
var tempItem04;
var tempItem05;
var tempItem06;
var tempItem07;
var tempItem08;
var tempItem09;
var tempItem10;


var tempInnerItem01;
var tempInnerItem02;
var tempInnerItem03;
var tempInnerItem04;
var tempInnerItem05;
var tempInnerItem06;
var tempInnerItem07;
var tempInnerItem08;
var tempInnerItem09;
var tempInnerItem10;




var tempSubItems;

function initArrays()
{
	var caption;
	var href;
	var number;
	var subSections;
	
	
	/* prepare values */
	caption = new String("Smelling Well");
	href = new String("smelling_well/");
	number = 2;
	subSections = new Array();
	
	/* construct */
	tempItem02 = new menuItem(caption, href, number, subSections);
	

	/* prepare subsections */
	
	/* prepare values */
	caption = new String("Bacteria Galore");
	href = new String("children/BacteriaGalorebySundayatFour.htm");
	number = 1;
	subSections = new Array();
	
	/* construct */
	tempInnerItem01 = new menuItem(caption, href, number, subSections);


	/* prepare values */
	caption = new String("The Skunk");
	href = new String("children/TheSkunkThatStunk.htm");
	number = 2;
	subSections = new Array();
	
	/* construct */
	tempInnerItem02 = new menuItem(caption, href, number, subSections);


	/* prepare values */
	caption = new String("Fifty Quizzes");
	href = new String("children/FiftyQuizzesforYoungWizzes.htm");
	number = 3;
	subSections = new Array();
	
	/* construct */
	tempInnerItem03 = new menuItem(caption, href, number, subSections);


	/* prepare values */
	caption = new String("Tower of Babel");
	href = new String("children/melrosenberg.comTowerofBabel.htm");
	number = 4;
	subSections = new Array();
	
	/* construct */
	tempInnerItem04 = new menuItem(caption, href, number, subSections);



	/* prepare values */
	caption = new String("Children's Corner");
	href = new String("children/");
	number = 3;
	subSections = new Array(tempInnerItem01, tempInnerItem02, tempInnerItem03, tempInnerItem04);
	
	/* construct */
	tempItem03 = new menuItem(caption, href, number, subSections);
	


	/* prepare subsections */
	
	/* prepare values */
	caption = new String("Jazz - Upcoming Events");
	href = new String("art/index.htm");
	number = 1;
	subSections = new Array();
	
	/* construct */
	tempInnerItem01 = new menuItem(caption, href, number, subSections);


	/* prepare values */
	caption = new String("Jazz - Recent Performances");
	href = new String("art/RecentPerformances.htm");
	number = 2;
	subSections = new Array();
	
	/* construct */
	tempInnerItem02 = new menuItem(caption, href, number, subSections);


	/* prepare values */
	caption = new String("Jazz - Music Files");
	href = new String("art/MusicFiles.htm");
	number = 3;
	subSections = new Array();
	
	/* construct */
	tempInnerItem03 = new menuItem(caption, href, number, subSections);


	/* prepare values */
	caption = new String("CD - The Aroma of You");
	href = new String("art/TheAromaOfYou.htm");
	number = 4;
	subSections = new Array();
	
	/* construct */
	tempInnerItem04 = new menuItem(caption, href, number, subSections);


	/* prepare values */
	caption = new String("Poetry");
	href = new String("art/melspoetry.htm");
	number = 5;
	subSections = new Array();
	
	/* construct */
	tempInnerItem05 = new menuItem(caption, href, number, subSections);





	/* prepare values */
	caption = new String("Art");
	href = new String("art/");
	number = 4;
	subSections = new Array(tempInnerItem01, tempInnerItem02, tempInnerItem03, tempInnerItem04, tempInnerItem05);
	
	/* construct */
	tempItem04 = new menuItem(caption, href, number, subSections);
	
	
	/* prepare values */
	caption = new String("Inventions &amp; Products");
	href = new String("invitations_and_products/");
	number = 5;
	subSections = new Array();
	
	/* construct */
	tempItem05 = new menuItem(caption, href, number, subSections);
	
	
	/* prepare values */
	caption = new String("About");
	href = new String("about/");
	number = 6;
	subSections = new Array();
	
	/* construct */
	tempItem06 = new menuItem(caption, href, number, subSections);
	
	
	
	
	sections = new Array( new menuItem("Home", "", 0, new Array() ), tempItem02, tempItem03, tempItem04, tempItem05, tempItem06);
}

function writeMenu(distanceFromRoot, currentItems)
{
	var i;
	
	initArrays();
	for(i=0; i<currentItems.length; i++)
		currentItems[i] = eval(currentItems[i]);
	writeMenu1(distanceFromRoot, currentItems, 0, sections)
}

function writeMenu1(distanceFromRoot, currentItems, index, theSections)
{
	var innerIndex;
	var n;
	var currentStyle;
	var currentSection;
	var currentNumber;
	var linkPrefix;
	var processCurrent;
	
	if(currentItems == null)
		return (0);
	
	n = theSections.length;
	
	if(n == 0)
		return (0);
	
	if(currentItems[index] == 0)
		processCurrent = false;
	else
		processCurrent = true;
	
	currentStyle = menuStyles[index];
	linkPrefix = repeatString(new String("../"), distanceFromRoot);
	
	document.write('<table border="0" cellpadding="0" cellspacing="0" class="' + currentStyle.tableStyle + '">\n');
	document.write('\t<tr>');
	
	for(innerIndex = 0; innerIndex < n; innerIndex++)
	{
		currentSection = theSections[innerIndex];
		
		document.write('\t\t<td class="');
		
		if(processCurrent == true)
		{
			if(currentSection.number == currentItems[index])
			{
				document.write(currentStyle.currentItem);
				currentNumber = innerIndex;
			}
			else
			{
				document.write(currentStyle.otherItems);
			}
		}
		else
		{
			document.write(currentStyle.otherItems);
		}
		
		document.write('">\n');
		document.write('\t\t\t<a href="' + linkPrefix + currentSection.link + '" class="aSectionNavBar">' + currentSection.caption);
		document.write('</a>\n');
		document.write('\t\t</td>');
	}
	
	if (index == 0)
	{
		document.write('<td width="100%" class="' + currentStyle.otherItems + '"><a href="mailto:melros@post.tau.ac.il" class="aSectionNavBar">e-Mel</a></td>');
	}
	else
	{
		document.write('<td width="100%" class="' + currentStyle.otherItems + '">&nbsp;</td>');
	}
	
	//document.write('<td width="100%" class="' + currentStyle.otherItems + '">&nbsp;</td>');
	document.write('\t</tr>\n');
	document.write('</table>\n');
	
	if((processCurrent == true) && (currentItems.length != 1))
		writeMenu1(distanceFromRoot, currentItems, index + 1, theSections[currentNumber].getSubSections());
}

function repeatString(s, num)
{
	var i;
	var temp = new String();
	
	for(i=0; i<num; i++)
	{
		temp = temp + s;
	}
	
	return temp;
}