//declarations
var w;
var pageNo;
var docPath="";
var noPages=1;

// set up path to files and number of pages
function makeDoc(pathIn,noPagesIn)
	{
		docPath=pathIn;
		noPages=noPagesIn;
		start();
	}

// open a window to hold prospectus version for printing
function goPrint()
  {
/*
		if (w != null)
			{
				w.close();
			}
*/


		
		w=window.open(docPath+"printPages.html","printout");
		w.moveTo(0,0);
		w.resizeTo(800,600);
		w.focus();		
	}

// print the prospectus
function printOut()
  		{
  			alert("For best print results please use your browser's \"Page Setup\" menu to \nset the page to A4 portrait and the page margins to 13mm (0.5 inch)");
  			print();
  			close();
  		}
	
//go to start of document
function start()
	{
		pageNo=1;
		setPage();
		atStart();	
	}  		
  		
  		
//go to end of document
function end()
	{
		pageNo=noPages;
		setPage();
		atEnd();	
	}
	
	
//disable buttons that increment page no	
function atEnd()
	{
		document.getElementById("end1").disabled=true;
		document.getElementById("end2").disabled=true;
		document.getElementById("next1").disabled=true;
		document.getElementById("next2").disabled=true;
		document.getElementById("start1").disabled=false;
		document.getElementById("start2").disabled=false;
		document.getElementById("prev1").disabled=false;
		document.getElementById("prev2").disabled=false;
	}
	
//disable buttons that decrement page no	
function atStart()
	{
		document.getElementById("start1").disabled=true;
		document.getElementById("start2").disabled=true;
		document.getElementById("prev1").disabled=true;
		document.getElementById("prev2").disabled=true;
		document.getElementById("end1").disabled=false;
		document.getElementById("end2").disabled=false;
		document.getElementById("next1").disabled=false;
		document.getElementById("next2").disabled=false;
	}
	
// activate all navigation buttons
function allActive()
	{
		document.getElementById("start1").disabled=false;
		document.getElementById("start2").disabled=false;
		document.getElementById("prev1").disabled=false;
		document.getElementById("prev2").disabled=false;
		document.getElementById("end1").disabled=false;
		document.getElementById("end2").disabled=false;
		document.getElementById("next1").disabled=false;
		document.getElementById("next2").disabled=false;
	}
	
// increment page no	
function inc()
	{
		pageNo++;
		setPage();
		if (pageNo == noPages)
			{
				atEnd();
			}
		else
			{
				allActive();
			}
	}	
	
	
// decrement page no
function dec()
	{
		pageNo--;
		setPage();
		if (pageNo == 1)
			{
				atStart();
			}
		else
			{
				allActive();
			}
	}	

//set page viewed and counter to page no
function setPage()
	{
		document.getElementById("pageCount1").innerHTML="Page "+pageNo+" of "+noPages;
		document.getElementById("pageCount2").innerHTML="Page "+pageNo+" of "+noPages;
		document.getElementById("pFrame").src=docPath+pageNo+".html";
		window.location="#top";
	}