///////////////////////////////////////////////////////////////////////////////
//menu.js 
///////////////////////////////////////////////////////////////////////////////
//
//vertical menu program using style sheets
//works on ie and navigator
//functions: makemenu(), changeClass(), LoadHtml(strUrl) 
//
//Author: Vincent Chow 
//Copyright (c)2004 by Vincent Chow.
//
///////////////////////////////////////////////////////////////////////////////

//initialize variables
//arrays of the menu descriptions and urls
	var arrHref = new Array("index.html","mccAbout.htm","mccCFY.htm","mccChampions.htm","mccArchive.htm","mccGrandpp.htm","mccSchedule.htm","mccLinks.htm","mailto:chessking123@hotmail.com"); 
	var arrDescription = new Array("Home","About Us","Chess For Kids","Champions List","Archives","Grand Prix","Schedule","Links","Email Us");

//identify current page to disable link
	var sThisUrl = new String(parent.location);
	var iPosSlash = sThisUrl.lastIndexOf("/");
	var currPage = sThisUrl.substr(iPosSlash+1, eval(sThisUrl.length-iPosSlash));
	var iNumberOfUrls = arrHref.length;

/////////////////////////////////////////////////////////
//writes the menu to page
/////////////////////////////////////////////////////////
function makemenu()
{
	document.write("<form>");
	document.write("<TABLE NAME='tblVerticalMenu' id='tblVerticalMenu' BORDER=0 CELLSPACING=0 CELLPADDING=0>");
	
	if (currPage.length==0)	{currPage="index.html"}	//if page is blank such as http://www.../chess/
	for (i=0;i<iNumberOfUrls;i++)
	{
  	  document.write("	<TR>");
	  document.write("		<TD align='right'>");
	  strUrl = arrHref[i];
	  strText = arrDescription[i];
	  if  (strUrl!=currPage)
		{
			document.write("<input type='text' id='mnuv" + i + "' name='mnuv" + i + "' class='buttondefault' onclick='changeClass(this,\"buttonclick\"); LoadHtml(\"" + strUrl + "\")' onMouseOver='changeClass(this,\"buttonhover\");' onMouseOut='changeClass(this,\"buttondefault\");' value='" + strText + "' readonly />");
		}
		else
		{
			document.write("<input type='text' id='mnuv" + i + "' name='mnuv" + i + "' class='buttondefault' style='cursor:default; color:brown' value='" + strText + "' readonly />");
		}
	  document.write("		</TD>");
	  document.write("	</TR>");
	}

	document.write("</TABLE>");
	document.write("</form>");
}

/////////////////////////////////////////////////////////
//redirect to another page
/////////////////////////////////////////////////////////
function LoadHtml(strUrl) 
{
	window.location.href = strUrl;
}

/////////////////////////////////////////////////////////
//change class i.e. display for mouse hover, out, click
/////////////////////////////////////////////////////////
function changeClass(oBtn,sNewClass)
{
	oBtn.className=sNewClass;
}