
// JavaScript Document
var MyLocation=window.location; 
var ThisPageNumber=0;

database=new Array("index.htm","1.htm","2.htm","3.htm","4.htm","5.htm","6.htm","7.htm","8.htm","9.htm","10.htm","11.htm","12.htm","13.htm","14.htm","15.htm","16.htm","17.htm","18.htm","19.htm","20.htm","21.htm","22.htm","23.htm","24.htm","25.htm","26.htm","27.htm","28.htm","29.htm","30.htm","31.htm","32.htm","33.htm","34.htm","35.htm","36.htm","37.htm","38.htm","39.htm","40.htm","41.htm","42.htm","43.htm","44.htm","45.htm","46.htm","47.htm");
//The above is all you need to change!
//We want to automatically discover the number of files
NumberOfFiles=database.length;
//Next find out which page, this one is//
//We use the location.href property and extract the filename
//from this string using lastIndexOf:
StringA=location.href;
LengthA=StringA.length;
A=StringA.lastIndexOf('/')+1;
ThisFilename=StringA.substring(A,LengthA);
//Now we find the current page nunmber (in the list)
//Remember that Arrays start at 0 and end at number of 
//elements less one. So the last element is:
n=NumberOfFiles-1;
//Now we look through to list to find our file, and 
//therefore, its number in the list:
for (var i = 0; i <= n; i++)
{
if (database[i]==ThisFilename)
{ThisPageNumber=i;
}
}


function GoForward(){ 
ThisPageNumber=ThisPageNumber+1; 
if (ThisPageNumber >=NumberOfFiles) { 
answer=confirm("You are at the end of the present series. "+ 
"Press ok to go to the beginning. Cancel to stay here"); 
if (answer!=0) {ThisPageNumber=0; 
window.location=database[ThisPageNumber];
}
ThisPageNumber=ThisPageNumber-1; 
} 
else { 
window.location=database[ThisPageNumber]; 

//from this string using lastIndexOf:
StringA=location.href;
LengthA=StringA.length;
A=StringA.lastIndexOf("/")+1;
ThisFilename=StringA.substring(A,LengthA);
A=StringA.lastIndexOf("/")+1;
ThisFilename=StringA.substring(A,LengthA);
n=NumberOfFiles-1;

//Now we look through to list to find our file, and 

//therefore, its number in the list:

for (var i = 0; i <= n; i++)
{
if (database[i]==ThisFilename);
ThisPageNumber=i;
}
}
}

function GoBack() { 
if (ThisPageNumber <=0) { 
alert("You are at the beginning of this series"); 
} 
else{ ThisPageNumber=ThisPageNumber-1; 
window.location=database[ThisPageNumber]; 
} } 



//determine the numbers of the previous and the next pages//
// this goBack does not work!!
/*function goBack(){
if (ThisPageNumber-1<=0)
//We don't want to go into negative numbers or numbers
//bigger than the number of files! So if the file number less
//one is less than zero, there is nowhere left to go!
{
alert("You are at the beginning of the series")
}
//Otherwise we just take one of the current file number
//and get the number for the previous file:
else
{window.location=database[ThisPageNumber-1]}}
function goForward(){
if (ThisPageNumber+1>n){
alert("You are at the end of the series")
//If the user is clicking on the last file, he or she
//cannot go forward. Otherwise, the next file is the current
//file number plus one:
}
else
{window.location=database[ThisPageNumber+1]}
document.write('<br>'+"this page string is "+StringA);
}
//and so that's our code. All we have to do is to change files
//in the Array database! Nice and lazy!*/
