	function fn() 
	{
		var chapdir = document.location.pathname;
		//the "code" parameter should be the stem used for all the file and folder names
		//the key is the number of letters in the code multiplied by 42
//		var URL = "../../../cgi-bin/NewSmartCompile.pl?code=spval&ext=html&key=210&path=" + chapdir;
		var URL = "http://www.codepublishing.com/cgi-bin/NewSmartCompile.pl?code=winslow&ext=html&key=294&style=old&path=" + chapdir;
	
		document.location.href = URL;
	}

	function init()
	{
		
		var e = document.getElementById('mainContent');
		var f = buildForm();
		//stick the form into the document as the last thing before the </blockquote>
		var penultimate = e.lastChild;
    	try { //this works only in IE8
		   penultimate.style.marginBottom="1em";
  		}
  		catch(err) { //this works only in Firefox
            penultimate.style="margin-bottom:1em";
         }
		e.appendChild( f );
		var g = document.getElementsByTagName('input');
		//attach the fn() function to the form button
		g[0].onclick = function(){ fn(); };
		
	}
	
	//constructs the "compile chapter" form
	function buildForm()
	{
		var myForm = document.createElement( 'form' );
		var myPara = document.createElement( 'p' );
		myPara.className = 'show';
		var button = document.createElement('input');
		button.setAttribute('value', "Compile Title");
		button.setAttribute('type', "button");
		myPara.appendChild(button);
		myForm.appendChild(myPara);
		return myForm;
	
	}
	
	window.onload = function(){ init(); };
