function adjustURLs()
/*
	Adjusts the URLs of the links on a category page so that they point to the appropriate web pages if the box at the bottom of the page is unchecked, and to the PDF files if it is.
*/
{
	var wantsPDF = document.getElementById("PDFcheckbox").checked;
	
	var linktable = document.getElementById("toc");
	
	var links = linktable.getElementsByTagName("a");
	
	var url, urlbase, urlwork;
	var category, page;
	var arguments, tokens, token;
	for (var i=0; i<links.length; i++)
	{
		url = (links[i].href).toLowerCase();
		
		if ( (url.match("category=")) && (url.match("page=")) && wantsPDF )  // if we're converting non-PDF => PDF
		{
			urlbase = url.substring(0, url.lastIndexOf("/")+1);
			arguments = url.split("?")[1];
			tokens = arguments.split("&");
			for (var j=0; j<tokens.length; j++)
			{
				token = tokens[j].split("=");
				if (token[0]=="category")
					category = token[1];
				else if (token[0]=="page")
					page = token[1];
			}
			links[i].href = urlbase +  category + "/" + page + ".pdf";
		}
		else if (url.match(".pdf") && !wantsPDF)		// converting the other way
		{
			urlwork = url.substring(0,url.lastIndexOf("/"))
			urlbase = urlwork.substring(0, urlwork.lastIndexOf("/")+1);
			category = url.substring(urlwork.lastIndexOf("/")+1, url.lastIndexOf("/"));
			page = (url.substring(url.lastIndexOf("/")+1)).replace(/.pdf/, "");
			
			links[i].href = urlbase + "getdocument.php?category=" + category + "&page=" + page;
		}
	}
	
	return;	
}
