/**********************************************************************
indexpage.js contains declarations for the indexpage object
***********************************************************************/ 

//alert ('indexpage')
    
// create a new indexpage entry
function entry (theID,theCategory,theTitle,thelink) {
    this.ID	= theID
    this.category = theCategory;
    this.title = theTitle;
    this.link = thelink
}


// ******************************************
// * menu constructor creates a new menu
// ******************************************
function indexpage () {
    this.numberEntries = 0;                               // No menu entries when first created
    this.entries = new Array();                           // Array of entries is initially empty
    this.addEntry = indexpage_addEntry;             
    this.display = indexpage_display;  			  
    this.nextprior = indexpage_nextprior;
}


// ******************************************
// menu_addEntry adds an item to the gallery
// ******************************************
function indexpage_addEntry (entryID, entryCategory, entryTitle, entryLink) {
    this.numberEntries += 1;
    this.entries[this.numberEntries-1] = new entry(entryID, entryCategory, entryTitle, entryLink);    

}



// *********************************************
// * indexpage_nextprior
// *********************************************
function indexpage_nextprior (theCategory, theID) {
//alert ('NP');

	var sThisId = "";
	var sThisText = "";
	var sThisLink = "";
	
	var sPriorId = "";
	var sPriorText = "";
	var sPriorLink = "";
	
	var sNextId = "";
	var sNextText = "";
	var sNextLink = "";
	var sTopLink = "";
	
    var iFound = "0";
  
//***************************************
//  Process each entry in the gallery,
// ***************************************
     iFound = "0";
     for (var i = 0; i <= this.numberEntries -1; i++) {
        var my = this.entries[i]; 
		if (my.category.toLowerCase() == theCategory.toLowerCase()) {
//alert ('ifound=' + iFound + ', my.ID ' + my.ID);

				if (iFound == "1") {
					sNextId = my.ID;
					sNextText = my.title;
					sNextLink = my.link;
                    iFound = "2";
//alert ('set next ' + sNextId);
				}

				if (my.ID == theID) {
					sTopLink = my.link;
					sPriorLink = sThisLink;
					sPriorId = sThisId;
					sPriorText = sThisText;
                    iFound = "1";
//alert ('set prior ' + sPriorId);
				}

				sThisId = my.ID
				sThisText = my.title
				sThisLink = my.link

				
		} // End If

     }  // End for

	document.write( '<TR>' ); 
	document.write( '<TD>' ); 

    document.write( '<table Class="navigation" border="0" cellspacing="0" cellpadding="0" align=left >' ); 
	document.write( '<TR>' ); 
	document.write( '	<TD class=footer align=left width=100 >' ); 
	document.write ( '		<A href="#pagetop">' );
	document.write ( '		<img src="images/navtop.gif" border="0" alt="Return to Top of Page">');
	document.write( '			 <br>Top');
			document.write ( '		</a>' );
	document.write ( '	</TD>' ); 
	
	if (sPriorId != "") {
//alert ('P ' + sPriorLink);
		document.write( '	<TD width=50 align=center>');
		document.write( '		<a href=' + sPriorLink + ' target=_self>');
		document.write( '		<img src="images/navprior.gif" border=0 width=32');
		document.write( '			alt="Prior ' + theCategory + '">');
		document.write( '			 <br>Previous');
		document.write( '		</a>')
		document.write( '	</TD>' );
	}

	if (sNextId != "") {
//alert ('N ' + sNextLink);
		document.write( '	<TD width=100 align=center>');
		document.write( '		<a href=' + sNextLink + ' target=_self>');
		document.write( '		<img src="images/navnext.gif" border=0 width=32 ');
		document.write( '			 alt="Next ' + theCategory + '">');
		document.write( '			 <br>Next');
		document.write( '		</a>')
		document.write( '	</TD>' );
	}

//***************************************
//  End the Table
// ***************************************
	document.write( '</TR>' );
    document.write ( '</TABLE>' );
	
	document.write( '</TD>' ); 
	document.write( '</TR>' ); 




}
	
// *********************************************
// * indexpage_displayindex
// *********************************************
function indexpage_display (theCategory, theTitle) {
//alert ('D');
	
	var asText=0;
	
   // Table Header Row Details
    document.write( '<table Class="defaulttext" cellspacing="0" cellpadding="0">' ); 
	document.write( '<TR>' ); 
	document.write( '<TD width="30" height="1"><IMG SRC="images/spacer.gif" HEIGHT="1"></TD>' );
	document.write( '<TD width="180"></TD>' );
	document.write( '</TR>' );
    document.write( '<TR height="40"><TD colspan="2" width="210">' );
    document.write( '<b>' + theTitle + '</b>' );
    document.write( '</td></tr>');

//***************************************
//  Process each entry in the gallery,
// ***************************************
     for (var i = 0; i <= this.numberEntries -1; i++) {
          var my = this.entries[i]; 
        if (my.category.toLowerCase() == theCategory.toLowerCase()) {
                document.write( '<TR>' );
                document.write( '<TD align="center"><IMG SRC="images/smallbullet.jpg"></TD>' );
	            document.write( '<TD>');        
	            document.write( '<a href="' + my.link + '" target="_self">');
	            document.write(my.title);
	            document.write( '</a>');
	    		document.write( '</TD></TR>');
		    } // End If

         }  // End for

//***************************************
//  Space before Poster
// ***************************************
	document.write( '<TR>' ); 
	document.write( '<TD width="20" height="1"><IMG SRC="images/spacer.gif" HEIGHT="10"></TD>' );
	document.write( '<TD width="100"></TD>' );
	document.write( '</TR>' );

//***************************************
//  End the Table
// ***************************************
     document.write ( '</TABLE>' );
                 
} // End Function

// *****************************************
// * Create an instance of the Indexpage object
// *****************************************
var Indexpage = new indexpage();

