
//----------------------------------------------------------------------------
// Global variables used in drawing the menu.
//----------------------------------------------------------------------------

	// Main menu
	var gMenuNormalSrc = new Array(10);
	var gMenuHiliteSrc = new Array(10);
	var gMenuSelectSrc = new Array(10);
	var gMenuSelRedSrc = new Array(10);
	var gMenuWidth = new Array(10);
	var gMenuHREF = new Array(10);
	// Sub menu
	var gSubMenuWidth = [ [0], [0, 61, 60, 54, 43, 319], [0, 106, 67, 58, 34, 81, 93, 44, 54], [0, 61, 36, 81, 359], [0, 106, 90, 37, 304], [0, 128, 68, 37, 78, 226], [0, 38, 45, 454], [0, 37, 34, 33, 68, 365], [0, 49, 44, 35, 33, 68, 56, 46, 45, 161] ];
	var gSubMenuHeight = 15;
	var gSubMenuHREF = [ ["x"], ["x", "../general/basics_01.htm", "../diary/diary_index.htm", "../events/events.htm", "../general/links_01.htm"], ["x", "../sf/sf.htm", "monterey_01.htm", "carmel_01.htm", "napa_01.htm", "sausalito_01.htm", "svalley_01.htm", "areas.htm"], ["x", "spots.htm", "transportation.htm", "sfshopping.htm"], ["x", "sf.htm", "sv.htm", "discover/discover_index.htm"], ["x", "mall.htm", "brands.htm", "market.htm", "souvenir_01.htm"], ["x", "parks.htm", "museums.htm"], ["x", "general.htm", "transportation.htm", "weather.htm", "send_question.htm"], ["x", "", "", "", "", "", "", "", ""] ]
//----------------------------------------New---------------------------------
	var gPageIndex = 0;
	var gPageData = [];
	var gPathPrefix = "";
	

//----------------------------------------------------------------------------
// Init Page
//----------------------------------------------------------------------------

	window.name = "California Asobikata";

//----------------------------------------------------------------------------
// asbLoadNavigationImages
//----------------------------------------------------------------------------
// This function loads in all menu images into the an array of cache.
//----------------------------------------------------------------------------

function asbLoadNavigationImages() {
	// First define image source files
	for (i=1; i<=9; i=i+1)
	{
		gMenuNormalSrc[i] = "../nav/images/mm_nm_0" + i + ".gif"
		gMenuHiliteSrc[i] = "../nav/images/mm_hi_0" + i + ".gif"
		gMenuSelectSrc[i] = "../nav/images/mm_sl_0" + i + ".gif"
		gMenuSelRedSrc[i] = "../nav/images/mm_rd_0" + i + ".gif"
	}
	
	// Now define image width
	gMenuWidth[1] = 62;
	gMenuWidth[2] = 86;
	gMenuWidth[3] = 50;
	gMenuWidth[4] = 64;
	gMenuWidth[5] = 50;
	gMenuWidth[6] = 50;
	gMenuWidth[7] = 51;
	gMenuWidth[8] = 87;
	gMenuWidth[9] = 37;
	
	// Now define HREF
	gMenuHREF[1] = "../index.htm";
	gMenuHREF[2] = "../areas/areas.htm";
	gMenuHREF[3] = "../sf/sf.htm";
	gMenuHREF[4] = "../eat/eat.htm";
	gMenuHREF[5] = "../shop/shop.htm";
	gMenuHREF[6] = "../play/play.htm";
	gMenuHREF[7] = "../faq/faq.htm";
	gMenuHREF[8] = "../world/world.htm";
	gMenuHREF[9] = "";
}

//----------------------------------------------------------------------------
// asbGenerateNavigation
//----------------------------------------------------------------------------
// This function generates the navigation menu/submenu at the top of the page.
// It is called by individual web pages at the beginning of page loading.
//
// Parameters:	
//		- menuIndex: Must be between 1 and 9, corresponding to the top menu 
//		  item.
//		- submenuIndex: Index for the current submenu to be in bold.  If it's
//		  0, then it's the "intro" page and nothing will be in bold.
//----------------------------------------------------------------------------

function asbGenerateNavigation( inMenuIndex, inSubmenuIndex, inDepth ) {

	var pathprefix = asbAdjustPathDepth( inDepth );
	asbLoadNavigationImages();

	// First write open the stream to the document and write out top level table
	document.open("text/html");
	document.writeln('<P><CENTER><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>');
	document.writeln('<TR>');
	document.writeln('<TD VALIGN=top ROWSPAN=2 WIDTH=50>');		// logo at the top left
	document.writeln('<P><IMG SRC="' + pathprefix + '../nav/images/logo.gif" WIDTH=70 HEIGHT=53 BORDER=0 ALIGN=bottom></P>');
	document.writeln('</TD>');
	document.writeln('<TD VALIGN=top>');
	document.writeln('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>');
	document.writeln('<TR>');
	
	// Now loop through each menu item and write selected (sl) or unselected (nm) images with right rollover (hi)
	for (i=1; i<=9; i=i+1)
	{
		document.writeln('<TD VALIGN=bottom WIDTH=' + gMenuWidth[i] + '>');
		if ( i == inMenuIndex ) {		
			// Need to write up "selected" image without rollover
			if ( inSubmenuIndex == 0 ) {	// No submenu selected, so display "selected" red menu and no HREF
				document.writeln('<P><IMG SRC=' + pathprefix + gMenuSelRedSrc[i] + ' WIDTH=' + gMenuWidth[i] + ' HEIGHT=37 BORDER=0 NAME="menuImage' + i + '"' + ' ALIGN=bottom></P>');
			}
			else {		// Submenu is selected, so display the normal black menu
				document.writeln('<P><A HREF=' + pathprefix + gMenuHREF[i] + ' TARGET="_top"><IMG SRC=' + pathprefix + gMenuSelectSrc[i] + ' WIDTH=' + gMenuWidth[i] + ' HEIGHT=37 BORDER=0 NAME="menuImage' + i + '"' + ' ALIGN=bottom></A></P>');
			}
		} 
		else {					
			// Write out "unselected" image with "hilite" rollover
			if ( i == 9 ) {			// special case the last item (the blank space), which doesn't have HREF
				document.writeln('<P><IMG SRC=' + pathprefix + gMenuNormalSrc[i] + ' WIDTH=' + gMenuWidth[i] + ' HEIGHT=37 BORDER=0 NAME="menuImage' + i + '"' + ' ALIGN=bottom></P>');
			}
			else {
				document.writeln('<P><A HREF=' + pathprefix + gMenuHREF[i] + ' onMouseOver="document.menuImage' + i + '.src=' + "'" + pathprefix + gMenuHiliteSrc[i] + "'" + '"' + ' onMouseOut="document.menuImage' + i + '.src=' + "'" + pathprefix + gMenuNormalSrc[i] + "'" + '"' + ' TARGET="_top"><IMG SRC=' + pathprefix + gMenuNormalSrc[i] + ' WIDTH=' + gMenuWidth[i] + ' HEIGHT=37 BORDER=0 NAME="menuImage' + i + '"' + ' ALIGN=bottom></A></P>');
			}
		}
		document.writeln('</TD>');
	}
	
	document.writeln('</TR>');
	document.writeln('</TABLE></TD>');
	document.writeln('<td width="5"></td>');		// space between menu and search box
	
	document.writeln('<td rowspan="2">');
	document.writeln('<!-- SiteSearch Google -->');
	document.writeln('<form method="get" action="http://www.google.co.jp/custom" target="google_window">');
	document.writeln('<table border="0" bgcolor="#ffffff">');
	document.writeln('<tr><td nowrap="nowrap" valign="top" align="left" height="32">');
	document.writeln('<a href="http://www.google.com/">');
	document.writeln('<img src="http://www.google.com/logos/Logo_25wht.gif" border="0" alt="Google" align="middle"></img></a>');
	document.writeln('</td>');
	document.writeln('<td nowrap="nowrap">');
	document.writeln('<input type="hidden" name="domains" value="asobikata.com"></input>');
	document.writeln('<input type="text" name="q" size="25" maxlength="255" value=""></input>');
	document.writeln('<input type="submit" name="sa" value="??"></input>');
	document.writeln('</td></tr>');
	document.writeln('<tr><td>&nbsp;</td><td nowrap="nowrap">');
	document.writeln('<table><tr><td>');
	document.writeln('<input type="radio" name="sitesearch" value="" checked="checked"></input>');
	document.writeln('<font size="-1" color="#000000">Web</font>');
	document.writeln('</td><td>');
	document.writeln('<input type="radio" name="sitesearch" value="asobikata.com"></input>');
	document.writeln('<font size="-1" color="#000000">asobikata.com</font>');
	document.writeln('</td></tr></table>');
	document.writeln('<input type="hidden" name="client" value="pub-0539040833160666"></input>');
	document.writeln('<input type="hidden" name="forid" value="1"></input>');
	document.writeln('<input type="hidden" name="ie" value="ISO-2022-JP"></input>');
	document.writeln('<input type="hidden" name="oe" value="ISO-2022-JP"></input>');
	document.writeln('<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1;"></input>');
	document.writeln('<input type="hidden" name="hl" value="ja"></input>');
	document.writeln('</td></tr></table>');
	document.writeln('</form>');
	document.writeln('<!-- SiteSearch Google -->');
	document.writeln('</td>');
	
	document.writeln('</TR>');
	document.writeln('<TR><TD VALIGN=top>');
	document.writeln('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>');
	document.writeln('<TR>');
	
	// Now write up sub-menu table
	for (i=1; i<gSubMenuWidth[inMenuIndex].length; i=i+1) {
		if ( inMenuIndex != 8 ) {		// only if it's not world menu
			if ( i != ( gSubMenuWidth[inMenuIndex].length - 1 ) ) {						// it's not the last item, which is a blank line and shouldn't have a link
				if ( i == inSubmenuIndex ) {
					document.writeln('<TD VALIGN=top WIDTH=' + gSubMenuWidth[inMenuIndex][i] + '><P><A HREF=' + pathprefix + gSubMenuHREF[inMenuIndex][i] + ' TARGET="_top"><IMG SRC="' + pathprefix + '../nav/images/sm_rd_0' + inMenuIndex + '_0' + i + '.gif" WIDTH=' + gSubMenuWidth[inMenuIndex][i] + ' HEIGHT=15 BORDER=0 ALIGN=bottom></P></TD>');
				}
				else {
					document.writeln('<TD VALIGN=top WIDTH=' + gSubMenuWidth[inMenuIndex][i] + '><P><A HREF=' + pathprefix + gSubMenuHREF[inMenuIndex][i] + ' TARGET="_top"><IMG SRC="' + pathprefix + '../nav/images/sm_nm_0' + inMenuIndex + '_0' + i + '.gif" WIDTH=' + gSubMenuWidth[inMenuIndex][i] + ' HEIGHT=15 BORDER=0 ALIGN=bottom></A></P></TD>');
				}
			}
			else { 						// it's the last item, so don't have HREF
				document.writeln('<TD VALIGN=top WIDTH=' + gSubMenuWidth[inMenuIndex][i] + '><P><IMG SRC="' + pathprefix + '../nav/images/sm_nm_0' + inMenuIndex + '_0' + i + '.gif" WIDTH=' + gSubMenuWidth[inMenuIndex][i] + ' HEIGHT=15 BORDER=0 ALIGN=bottom></P></TD>');
			}
		}
		else { 						// it's the world menu, no links for now
			document.writeln('<TD VALIGN=top WIDTH=' + gSubMenuWidth[inMenuIndex][i] + '><P><IMG SRC="' + pathprefix + '../nav/images/sm_nm_0' + inMenuIndex + '_0' + i + '.gif" WIDTH=' + gSubMenuWidth[inMenuIndex][i] + ' HEIGHT=15 BORDER=0 ALIGN=bottom></P></TD>');
					
		}
	}
	
	// Finally write up the rest of the page
	document.writeln('</TR></TABLE></TD></TR>');
	document.writeln('<TR><TD WIDTH=50 HEIGHT=5><P></P></TD><TD HEIGHT=5><P></P></TD></TR>');		// Blank 5 pixel high space
	document.writeln('</TABLE></CENTER></P>');
	document.close();
}


//----------------------------------------------------------------------------
// asbAdjustPathDepth
//----------------------------------------------------------------------------
//
// Parameters:	
//		- inMenuIndex: Must be between 1 and 9, corresponding to the top menu 
//		  item.
//		- inSubmenuIndex: Index for the current submenu to be in bold.  If it's
//		  0, then it's the "intro" page and nothing will be in bold.

function asbAdjustPathDepth( inDepth ) {

	var path = "";
	
	for (i=2; i<=inDepth; i=i+1) {
		path = "../" + path;
	}
	return path;
}

//----------------------------------------------------------------------------
// asbSelectPagePopupMenu
//----------------------------------------------------------------------------
//
// Parameters:	
//		- inURL: URL to jump to when the menu is selected.
//		- inMenuIndex: Menu for this page.  Bring it back to the original
//        state after user selection.


function asbSelectPagePopupMenu( inURL, inMenuIndex ){
	window.open( inURL, '_top' );
    document.pagePopupFormName.pagePopupName.selectedIndex=inMenuIndex;
}

//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
// absGetPathDepth
//----------------------------------------------------------------------------
//
// Parameters:	
//		- inDepth: Number of times "../" should be appended.
//----------------------------------------------------------------------------

function absGetPathDepth( inDepth ) {

	var path = "";
	
	for (i=1; i<=inDepth; i=i+1) {
		path = path + "../";
	}
	return path;
}
//----------------------------------------------------------------------------
// absInitialize
//----------------------------------------------------------------------------
// This function creates path prefix based on depth of web page
//
// Parameters:	
//		- inDepth: Depth from the root of the web site hierarchy at which the 
//		  calling web page resides.
//----------------------------------------------------------------------------

function absInitialize( inDepth ) {
	gPathPrefix = absGetPathDepth( inDepth );
	if ( gPageData.length ) {								// If it's a multi-page document
		var docName = absFindDocName( document.URL );	
		gPageIndex = absNameToPageIndex( docName );				
	}
}

//----------------------------------------------------------------------------
// absGeneratePagePopup
//----------------------------------------------------------------------------
// This function generates popup menu for navigating between pages.
//
// Parameters:	
//		- inSelected: Currently selected menu item. 
//----------------------------------------------------------------------------

function absGeneratePagePopup() {
	// First open the stream to the document and write out controls for the popup menu form
	document.open("text/html");
	document.writeln('<P CLASS=mainbody>');
	document.writeln('<FORM ACTION="" METHOD=POST name=PagePopupFormName>');
	document.writeln('<SELECT NAME=PagePopupName onChange="kySelectPagePopupMenu(this.options[this.selectedIndex].value, ' + gPageIndex + ')">');
	// Now loop through each menu item
	for (i=0; i<gPageData.length; i=i+1)
	{
		if ( i == gPageIndex ) {		
			// Need to put "SELECTED" 
			document.writeln('<OPTION VALUE="' + gPageData[i][1] + '" SELECTED>' + gPageData[i][0]);
		} 
		else {					
			document.writeln('<OPTION VALUE="' + gPageData[i][1] + '">' + gPageData[i][0]);
		}
	}
	// Finish up
	document.writeln('</SELECT></FORM></P>');
	document.close();
}

//----------------------------------------------------------------------------
// absGenerateNextPrevControls
//----------------------------------------------------------------------------
// This function generates next/previous button controls and [x/y] indicator.
// 
// Parameters:	
//		- inCurrent: Current page number from which this function was called.
//----------------------------------------------------------------------------

function absGenerateNextPrevControls() {
	var pageCount = gPageData.length - 2;		// "-2" for "Intro" and "Back to Main" items
	
	document.open("text/html");
	document.writeln('<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="2"><TR>');
	
	if ( gPageIndex != 0 ) {						// Not the first item - put "Previous" button and page indicator
		// "Previous" button
		document.writeln('<TD ALIGN="right" VALIGN="top">');
		document.writeln('<A HREF="' + gPageData[gPageIndex-1][1] + '" onmouseover="document.PrevPage.src=' + "'" + gPathPrefix + "images/page_prev_red.gif'" + '" onmouseout="document.PrevPage.src=' + "'" + gPathPrefix + "images/page_prev_blk.gif'" + '" onclick="document.PrevPage.src=' + "'" + gPathPrefix + "images/page_prev_blk.gif'; window.open('" + gPageData[gPageIndex-1][1] + "','_top')" + '"><img src="' + gPathPrefix + 'images/page_prev_blk.gif" width=90 height=22 border=0 align=bottom name=PrevPage></A></TD>');
		// Page indicator
		document.writeln('<TD CLASS="page_indicator" ALIGN="center" VALIGN="middle">' + '[' + gPageIndex + ' of ' + pageCount + ']</TD>');
	}
	if ( gPageIndex != pageCount ) {				// Not thel ast item - put "Next" button
		document.writeln('<TD ALIGN="left" VALIGN="top">');
		document.writeln('<A HREF="' + gPageData[gPageIndex+1][1] + '" onmouseover="document.NextPage.src=' + "'" + gPathPrefix + "images/page_next_red.gif'" + '" onmouseout="document.NextPage.src=' + "'" + gPathPrefix + "images/page_next_blk.gif'" + '" onclick="document.NextPage.src=' + "'" + gPathPrefix + "images/page_next_blk.gif'; window.open('" + gPageData[gPageIndex+1][1] + "','_top')" + '"><img src="' + gPathPrefix + 'images/page_next_blk.gif" width=90 height=22 border=0 align=bottom name=NextPage></A></TD>');
	}
	
	document.writeln('</TR></TABLE>');
	document.close();
}

///----------------------------------------------------------------------------
// absGenerateFooter
//----------------------------------------------------------------------------
// This function generates the separater bar, text based navigation menu, and
// the copyright notice.
//----------------------------------------------------------------------------

function absGenerateFooter() {
	// First write open the stream to the document and write out top level table
	document.open("text/html");
	document.writeln('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>');
	document.writeln('<TR><TD HEIGHT=2 BGCOLOR="#00FFFF"><P></P></TD></TR>');
	document.writeln('<TR><TD><CENTER><FONT SIZE="-1">Copyright 2001 asobikata.com, All Rights Reserved</FONT></CENTER></TD></TR>');
	document.writeln('<TR><TD HEIGHT=2 BGCOLOR="#00FFFF"><P></P></TD></TR></TABLE>');
	document.close();
}

//----------------------------------------------------------------------------
// absRandomImage
//----------------------------------------------------------------------------
//
// Parameters:	
//		- inImageCount: Number of images to pick from.
//		- inImageIndex: Index to the image in document where the random image
//		  should be displayed.
//		- inSourceLocation: Path and file name prefix of the image files,
//		  for example: "images/mainsplash/image_".  The random number and 
//		  ".jpg" suffix will be appended.
//----------------------------------------------------------------------------

function absRandomImage( inImageCount, inImageIndex, inSourceLocation ) {
   randomIndex = Math.round( Math.random() * inImageCount ) + 1;	// +1 fot 0->1-based
   document.images[inImageIndex].src = inSourceLocation + randomIndex + ".jpg"
}

//----------------------------------------------------------------------------
// absFindDocName
//----------------------------------------------------------------------------
//
// Parameters:	
//		- inURL: URL from which to extract the document name
// Returns:
//		- Document name
//----------------------------------------------------------------------------

function absFindDocName( inURL ) {
   var lastSlash = inURL.lastIndexOf( "/" );
   lastSlash++;									// Skip "/", or set to 0 if -1
   return inURL.slice( lastSlash, inURL.length );
}


//----------------------------------------------------------------------------
// absNameToPageIndex
//----------------------------------------------------------------------------
//
// Parameters:	
//		- inDocName: Name of the HTML document
// Returns:
//		- Page index of the document
//----------------------------------------------------------------------------

function absNameToPageIndex( inDocName ) {
	var pageIndex = 0;
	for ( x = 0; x < gPageData.length; x++ ) {
		if ( gPageData[x][1] == inDocName ) {
			pageIndex = x;
			break;
		}
	}
	return pageIndex;
}

//----------------------------------------------------------------------------





