var CONST_DESC   = 0;
var CONST_NEW    = 1;
var CONST_LINK   = 2;
var CONST_TARGET = 3;
var CONST_TITLE  = 4;

var pageList = new Array(
	new Array("Homepage"                           , false, "/"                      , "_parent", "Home"                           ),
	new Array("spacer", false, "", "",""),
	new Array("Introduction"                       , false, "intro.html"             , ""       , "Introduction"                   ),
	new Array("Design"                             , false, "design.html"            , ""       , "Design"                         ),
	new Array("Construction"                       , false, "construction.html"      , ""       , "Construction"                   ),
	new Array("Monitor"                            , false, "monitor.html"           , ""       , "Monitor"                        ),
	new Array("CP Facelift"                        , true , "cpfacelift.html"        , ""       , "New Control Panel Surface"      ),
	new Array("Control Panel"                      , false, "controlpanel.html"      , ""       , "Old Control Panel"              ),
	new Array("Interface"                          , false, "interface_ipac.html"    , ""       , "iPac Interface"                 ),
	new Array("Interface - Old"                    , false, "interface.html"         , ""       , "Old Interface"                  ),
	new Array("Track & Spinner"                    , true , "spinner.html"           , ""       , "New Trackball & Spinner Hookup" ),
	new Array("Trackball - Old"                    , false, "trackball.html"         , ""       , "Trackball"                      ),
	new Array("Thumb Buttons"                      , true , "thumbButtons.html"      , ""       , "Thumb Buttons"                  ),
	new Array("Keyboard Drawer"                    , false, "keyboard.html"          , ""       , "Keyboard Drawer"                ),
	new Array("Coin Door"                          , false, "coindoor.html"          , ""       , "Coin Door"                      ),
	new Array("Speakers"                           , false, "speakers.html"          , ""       , "Speaker Panel"                  ),
	new Array("Monitor Bezel"                      , false, "bezel.html"             , ""       , "Monitor Bezel"                  ),
	new Array("Finishing"                          , false, "finishing.html"         , ""       , "Finishing"                      ),
	new Array("Marquee Images"                     , false, "marquee.html"           , ""       , "Marquee Images"                 ),
	new Array("Computer"                           , false, "computer.html"          , ""       , "Computer"                       ),
	new Array("JAMMA!"                             , false, "jamma.html"             , ""       , "JAMMA!"                         ),
	new Array("Control Circuit"                    , false, "controlcircuit.html"    , ""       , "Control Circuit"                ),
	new Array("Relay Power"                        , true , "relaypowerstrip.html"   , ""       , "Relay Switch Power Strip"              ),
	new Array("Daphne"                             , true , "daphne.html"            , ""       , "Daphne"                         ),
	new Array("Materials & Cost"                   , false, "materials.html"         , ""       , "Materials & Cost"               ),
	new Array("spacer", false, "", "",""),
	new Array("Links"                              , false, "links.html"             , ""       , "Links"                          ),
	new Array("Mini MAME"                          , false, "minimame.html"          , ""       , "Mini MAME"                      ),
	new Array("Construction Journal"               , false, "journal/index.htm"      , ""       , "Construction Journal"           ),
	new Array("spacer", false, "", "",""),
	new Array("<img border='0' src='mameroms.gif'>", true , "http://www.mamedvds.com", "_blank" , ""                               ),
	new Array("Donate"                             , false, "donate.html"            , ""       , "Donate"                         )
);

var buttonImages = new Array(
	"images/buttons/01_button-rainbow.gif",
	"images/buttons/02_button-rainbow.gif",
	"images/buttons/03_button-rainbow.gif",
	"images/buttons/04_button-rainbow.gif",
	"images/buttons/05_button-rainbow.gif",
	"images/buttons/06_button-rainbow.gif",
	"images/buttons/07_button-rainbow.gif",
	"images/buttons/08_button-rainbow.gif",
	"images/buttons/09_button-rainbow.gif",
	"images/buttons/10_button-rainbow.gif",
	"images/buttons/11_button-rainbow.gif",
	"images/buttons/12_button-rainbow.gif",
	"images/buttons/13_button-rainbow.gif",
	"images/buttons/14_button-rainbow.gif",
	"images/buttons/15_button-rainbow.gif",
	"images/buttons/16_button-rainbow.gif",
	"images/buttons/17_button-rainbow.gif",
	"images/buttons/18_button-rainbow.gif"
)

// ##################################################################################
function DisplayMenuLinks() {
	var i;
	
	for (i = 0; i < pageList.length; i++) {
		DisplayLink( i, document );
		document.write("<br>\n");
	}
}

// ##################################################################################
function GetPageIndex( pageLink ) {
	var i;
	
	for (i = 0; i < (pageList.length - 1); i++) {
		if (pageList[i][CONST_DESC] != "spacer") {
			if (pageList[i][CONST_LINK] == pageLink) {
				return i;
			}
		}
	}
}

// ##################################################################################
function GetButtonIndex( pageLink ) {
	var buttonIndex = 0;
	var i;

	for (i = 0; i < pageList.length; i++) {
		if (pageList[i][CONST_DESC] != "spacer") {
			if (pageList[i][CONST_LINK] == pageLink) {
				return buttonIndex;
			}
			
			buttonIndex = (buttonIndex + 1) % buttonImages.length;
		}
	}
}

// ##################################################################################
function DisplayNextLink( pageLink, outDocument ) {
	var pageIndex = GetPageIndex(pageLink);

	pageIndex++;
	
	if (pageIndex < pageList.length) {
    	while ((pageList[pageIndex][CONST_DESC] == "spacer") && (pageIndex < pageList.length)) {
    		pageIndex++;
    	}
    
    	if (pageIndex < pageList.length) {	
    		outDocument.write("<p align='center'>");
    		DisplayLink( pageIndex, outDocument );
    		outDocument.write("</p><br><br>");
    	}
    }
}

// ##################################################################################
function DisplayLink(pageIndex, outDocument) {
	var pageDesc = pageList[pageIndex][CONST_DESC];
	var pageNew  = pageList[pageIndex][CONST_NEW];
	var pageLink = pageList[pageIndex][CONST_LINK];
	var pageTarget = pageList[pageIndex][CONST_TARGET];
	var pageButt = buttonImages[GetButtonIndex( pageLink )];

	if (pageDesc != "spacer") {
		outDocument.write("<a href='" + pageLink + "' ");
		if (pageTarget != "") outDocument.write("target=" + pageTarget);
		outDocument.write("><img src='" + pageButt + "' border='0' align='top' width='24' height='17'><font size=2 face=arial><b>" + pageDesc + "</b></font></a>");
		if (pageNew) outDocument.write("<font color='#FFFF00' face='Times New Roman'><b> *New*</b></font>");
	}
}

// ##################################################################################
function DisplayDesc(pageLink, outDocument) {
	var pageIndex = GetPageIndex(pageLink);
	var pageDesc = pageList[pageIndex][CONST_TITLE];
			
	outDocument.write("  <tr><td align=center><font size='6' face='Arial Black' Color='#aaaaff'><b>" + pageDesc + "</b></font><br><br></td></tr>");
}

// ##################################################################################
// ##################################################################################
// ##################################################################################


