
function button(name, link) {
	this.name = name;
	this.link = link;
}

function getButtonsForPage( pageName ) {
	var pageName = pageName.replace( /\.html/, "" ).toLowerCase();
	var buttons = [];
	var prefix;
	
	//because of web folder hierarchy, need to change link names
	if ( pageName == "index" ) {
		prefix = "pages/";
		buttons.push( new button("Home", "index.html") );
	}
	else {
		prefix = "";
		buttons.push( new button("Home", "../index.html") );
	}
	
	buttons.push( new button("Academics", prefix + "academics.html") );
	buttons.push( new button("Flash Cards", prefix + "flashcards.html") );
	buttons.push( new button("Master's Work", prefix + "masters.html") );
	buttons.push( new button("Notes", prefix + "notes.html") );
	buttons.push( new button("Professional", prefix + "professional.html") );
	buttons.push( new button("Projects", prefix + "projects.html") );
	buttons.push( new button("Resume", prefix + "resume.html") );
		
	return buttons;
}

function addButtons( pageName ) {
	
	//create the table and the list of buttons
	var bs = getButtonsForPage( pageName );
	var buttons = document.getElementById( "buttons" );
	var table = document.createElement( "table" );
	buttons.appendChild( table );
	
	for ( var i = 0; i < bs.length; i++ ) {
		//create row and column
		var tbody = document.createElement( "tbody" );
		var tr = document.createElement( "tr" );
		var td = document.createElement( "td" );
		td.setAttribute( "bgColor", "blue" );
		
		if (/msie/i.test (navigator.userAgent))
		{
		
		td.setAttribute( "bgColor", "white" );
			var link = document.createElement( "a" );
			link.setAttribute( "href", bs[i].link );
			link.appendChild( document.createTextNode( bs[i].name ) );
			td.appendChild( link );
		}
		else
		{
		
		//create the button with the link
		var link = document.createElement( "a" );
		link.setAttribute( "href", bs[i].link );
		link.style.textDecoration = "none";
		var but = document.createElement( "button" );
		but.setAttribute( "class", "first" );
		//but.onclick = function() { window.navigate( bs[i].link ); };
		but.appendChild( document.createTextNode( bs[i].name ) );
		link.appendChild( but );
		td.appendChild( link );
		
		}
		
		//append row to table
		tr.appendChild( td );
		tbody.appendChild( tr );
		table.appendChild( tbody );
	}
}
