function buildLinks(oname, oaddress, odirectory) {
  this.name = oname;
  this.address = oaddress;
	this.directory = odirectory;
}

links = new Array();
links[0] = new buildLinks('Contract' , 'es201.html' , 'es201');
links[1] = new buildLinks('Calendar' , 'calendar.html' , 'none');
links[2] = new buildLinks('Homework' , 'homework.html' , 'homework');
links[3] = new buildLinks('Communication' , 'comm.html' , 'comm');
links[4] = new buildLinks('Gradebook' , 'gradebook.html' , 'gradebook');
links[5] = new buildLinks('Other stuff' , 'other.html' , 'other');


var highLightColor = '#339933';
var buttonColor = '#0000ff';

//BEGIN FUNCTION WRITELINKS
function writeLinks() {
document.write('<table width="100%" summary="Menu" cellspacing="0" cellpadding="2">');
document.write('  <tr><td><br /><br /></td></tr>');

// CHECKS TO SEE IF CURRENT PAGE IS ROOT PAGE.  IF SO, WRITES LINKS AND RETURNS.
if (currentPage==links[0].address) {
  document.write('<tr><td class="leftmenu_sel">' + links[0].name + '</td></tr>');
  for (j=1; j<links.length; j++) {
	  document.write('<tr><td><a class="leftmenu" href="' + links[0].directory + '/' + links[j].address + '">' + links[j].name + '</a></td></tr>');
	}
	document.write('</table>');
	return;
}

// CHECKS TO SEE IF CURRENT PAGE IS IN A SUBDIRECTORY.  IF SO, WRITES LINKS AND RETURNS
for (i=1; i<links.length; i++) {
  if (currentDir==links[i].directory) {
	  document.write('<tr><td><a class="leftmenu" href="../../' + links[0].address + '">' + links[0].name + '</td></tr>');
	  for (j=1; j<links.length; j++) {
		  if (currentDir==links[j].directory) {
        document.write('<tr><td class="leftmenu_sel">' + links[j].name + '</td></tr>');
			}
			else {
			  document.write('<tr><td><a class="leftmenu" href="../' + links[j].address + '">' + links[j].name + '</a></td></tr>');
			}
		}
		document.write('</table>');
    return;
	}
}

// IF CURRENT PAGE IS NEITHER OF THE ABOVE, IT MUST ME IN MAIN DIRECTORY. WRITES LINKS AND RETURNS.
document.write('<tr><td><a class="leftmenu" href="../' + links[0].address + '">' + links[0].name + '</td></tr>');
for (i=1; i<links.length; i++) {
	if (currentPage==links[i].address) {
	  document.write('<tr><td class="leftmenu_sel">' + links[i].name + '</td></tr>');
	}
	else {
	  document.write('<tr><td><a class="leftmenu" href="' + links[i].address + '"> ' + links[i].name + '</a></td></tr>');
	}
}

document.write('</table>	');
//document.write('<center><hr><img src="' + currentPageImage + '.gif" alt="' + currentPageImage + '.gif"></center>');
}
// END FUNTION WRITELINKS



currentURL = document.URL;


// ONLINE USE "/" ON HARD DRIVE FOR IE USE "\\" -->
currentPage = currentURL.substring(currentURL.lastIndexOf("/")+1,currentURL.length);

endPos = currentURL.lastIndexOf("/");
startPos = currentURL.lastIndexOf("/",endPos-1);
currentDir = currentURL.substring(startPos+1,endPos);

writeLinks();



