

// Initialise the variables that are not document specific

	var NWTD1="<A href=\""  //NWTD=New Window <TD>
	var NWTD2="\"target=\"_blank\">"
	var JSTD1="<a href=\"javascript:parent."  //JSTD=javscript <TD>
	var JSTD2="()\">"
	var BasicEnd="</a>\r" // end of the anchor
	
// these variables need to be global but also need to be given document specific information
// this is done by the defLibraryVar function
	var AnchorTD1="" 
	var AnchorTD2="" 
	var TopButton=""
	var BackButton=""
	var gStyle=""
	var BasicTD="" 
	var gControls=""
	
	
	function buildpage() {
	// This function writes the Controls frame using the arguments passed
	// The first argument gives the number of navigation buttons:
	//		0=no buttons
	//		1="Top" Button
	//		a function name="Top" and "Back" Buttons, the function is the "Back" function
	//The remaining arguments are pairs of strings
	//  the first of each pair is the href, 
	//     starting with # if it is a link
	//	   	    		 NW to open a new window
	//					 < if it is a html snippet to be inserted
	//  				 any other character is a function in the parent document
	//	the second in the pair of strings is the text for the Anchor
		var len=buildpage.arguments.length
		var fstarg=buildpage.arguments[0] //fstarg is either 0,1 or the name of the "Back" function
		var text=gStyle //gStyle contains the initial head statements
		

		if(fstarg==1){text += TopButton} //One Control Button Top
		else if(fstarg!=0){ //Two Control Buttons Top and Back
		text += TopButton+"<a href=\"javascript:parent."+fstarg+"()\"><img src="+bBackButton+" height=\"30\" width=\"60\" border=\"0\"></a>\r";}
		

		for(var i=1; i<len; i=i+2){
			var anch=buildpage.arguments[i];
			var dtext=buildpage.arguments[i+1];
			text+=BasicTD
			if (anch.charAt(0)=="#") { // this anchor is a link
				text += AnchorTD1+anch+AnchorTD2+dtext+BasicEnd
				} else if (anch.substring(0,2)=="NW") {// this requires a new window to be opened
				text += NWTD1+anch.substring(2)+NWTD2+dtext+BasicEnd
				} else if (anch.substring(0,1)=="<") {//this is a html phrase eg heading not an anchor
				text += anch+"\r"
				} else	{   // this anchor calls a javascript function
				text += JSTD1+anch+JSTD2+dtext+BasicEnd
				}
			}
		text += "</table>\r</body>\r</html>"; //Finish off the page
		gControls.write(text); // write to Controls frame
		gControls.close(); // close the control frame
		}
		
		function MoveMain(hhref,nNav) // Moves the main page to hhrf and builds nNav()
		{window[MainName].location.href=MainSRC+"#"+hhref;
		nNav=eval(nNav);
		nNav();
		}
		
		function Init() { // converts gControls into a reference
		gControls=eval(gControls);
		}
		
		function defLibraryVar(Main,Controls,MainSRC,tTop,bBack,CSS,TDtag,NvHM){
		// Initialise the Anchor strings and others that need the document specific variables
		AnchorTD1="<a href=\""+MainSRC
		AnchorTD2=" \"target=\""+Main+"\">"
		TopButton="<td width=\"50%\"><a href=\"javascript:parent."+NvHM+"()\"><img src="+tTop+" height=\"30\" width=\"60\" border=\"0\"></a>\r<td width=\"50%\">";
		BackButton=bBack
		gStyle="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Strict//EN\">\r<html>\r<head>\r<title>PLMC Controls</title>\r<link rel=\"STYLESHEET\" type=\"text/css\" href=\""+CSS+"\">\r</head>\r<body>\r<table border=\"0\" width=\"100%\">\r<tr>";
		BasicTD="<TR><td class=\""+TDtag+"\" width=\"100%\">" //start of the table element
		gControls=eval("frames[\""+Controls+"\"].document")
		}

