function change(id,whichclass){
	var item = document.getElementById(id);
	item.className = whichclass;
}  

function linkto(page){
	window.location=page;
}

//////////////////////////////////////////////////////////////////
function printTopNav(relURL){
		/*in the function call, the relURL should point into the topnav folder.  
		The relURL must contain a trailing / or be the empty string */
		document.write('&nbsp;<a class="topnav" href="'
										+ relURL
										+ '../downloads/downloads.html">Downloads</a>&nbsp;<span class="topnav">|</span>&nbsp;'
										+'<a class="topnav" href="'
										+ relURL
										+ 'errata.html">Errata</a>&nbsp;<span class="topnav">|</span>&nbsp;'
										+	'<a class="topnav" href="'
										+ relURL
										+ 'toc.html">Table of Contents</a>&nbsp;<span class="topnav">|</span>&nbsp;'
										+'<a class="topnav" href="'
										+ relURL
										+ 'aboutauthors.html">The Authors</a>&nbsp;<span class="topnav">|</span>&nbsp;'
										+'<a class="topnav" href="'
										+ relURL
										+ 'feedback.html">Feedback</a>');

} // end printTopNav function


//////////////////////////////////////////////////////////////////
function printLeftNav(baseURL){
	/*in the function call, the baseURL should shift pwd from where
	this function is called to the webapps folder.  The baseURL must contain a trailing / or be the empty string */
	document.write("<div id=\"entry\" class=\"chapoff\" onmouseover=\"change('entry','chapon')\" "
									+ "onmouseout=\"change('entry','chapoff')\" onclick=\"linkto('"
									+ baseURL
									+ "../default.html')\">Entry Page</div>");
	document.write("<div id=\"home\" class=\"chapoff\" onmouseover=\"change('home','chapon')\" "
									+ "onmouseout=\"change('home','chapoff')\" onclick=\"linkto('"
									+ baseURL
									+ "index.html')\">Book Home</div>");
	
	// the chapter links
	var num=13;
	
	for(i=1;i<=num;i++){
	
		var filename = 'chap' + i + '.html';
		
		var chap = "";
		var desc = "";
		if(i<10){
			chap = 'chap0' + i;
			desc = "Chapter &nbsp;" + i;
		}
		else{
			chap = 'chap' +i;
			desc = "Chapter " + i;
		}
		
		document.write("<div id=\""
										+ chap
										+ "\" class=\"chapoff\" onmouseover=\"change('"
										+ chap
										+"','chapon')\" onmouseout=\"change('"
										+ chap
										+"','chapoff')\" onclick=\"linkto('"
										+ baseURL
										+ chap
										+"/"
										+ filename
										+"')\">"
										+ desc
										+"</div>");
	} //end for loop
			 
	document.write("<div id=\"appA\" class=\"chapoff\" onmouseover=\"change('appA','chapon')\" "
									+"onmouseout=\"change('appA','chapoff')\" onclick=\"linkto('"
									+ baseURL
									+"appA/appA.html')\">Appendix A</div>");
} // end printLeftNav function

//////////////////////////////////////////////////////////////////
function printFigureLinks(chap,numbers){
	for(i=0 ; i<numbers.length ; i++) {
		
		var whichfigure = numbers[i];
		desc = "Figure &nbsp;" + chap + '.' + whichfigure;
		var filename = "";

		if((whichfigure<10) || isNaN(whichfigure) ){
			filename = 'fig' + chap + '.0' + whichfigure + '.gif';
		}
		else{
			filename = 'fig' + chap + '.' + whichfigure + '.gif';
		}
		
	
		document.write("<a href=\"figures/"
										+ filename
										+ "\" class=\"red\">"
										+ desc
										+ "</a><br />");
	} // end for loop
} // end printFigureLinks function

	
	
	

			 	
			 