// Author: Robert Barnes
// Copyright: 2006

// define bar title array
var titleName = new Array(11);
titleName[1] = "Home";
titleName[2] = "Calgary Sites";
titleName[3] = "FTP Sites";
titleName[4] = "Other Sites";
titleName[5] = "Laser Discs";
titleName[6] = "Photos";
titleName[7] = "Search";
titleName[8] = "Timezones";
titleName[9] = "Programming Hints";
titleName[10] = "Calculators";
titleName[11] = "Statutory Holidays";

// set default value for selection
var mSelection = 1;

// get query string - look for "x" then split name and variable  ie: x=3
function getQueryVariable(variable)
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++)
	{
		var pair = vars[i].split("=");
		if (pair[0] == variable)
		{
			mSelection = pair[1];
//			return pair[1];
		}
	} 
//			for debuging purposes
//  		alert('Query Variable ' + variable + ' not found\n\npair[0] = ' + pair[0] + '\npair[1] = ' + pair[1]);
}

// show selected bar
function goBar(menuID)
{
	var ab;
	ab = document.getElementById(menuID);
	ab.style.background = "#364C7E";
	ab.style.border = "4px inset #006699";
}

// show unseleted bars
function backBar(menuID)
{
	var ab;
	ab = document.getElementById(menuID);
	ab.style.background = "#364C7E";
	ab.style.border = "4px outset #006699";
}

// do navigation once selected
function navDir(navID)
{
	mSelection = navID;
	document.form1.method = "post";

	if (mSelection == 1)
	{
		document.form1.action = "index.htm";
	}
	else
	{
		document.form1.action = "menu" + mSelection + ".htm?x=" + mSelection;
	}
	document.form1.submit();
/*
	// another way to submit
	location.href="menu" + mSelection + ".htm?x=" + mSelection;
	menuSel();
	init();
*/
}

// onload initialize
function init()
{
// Initilize the outset look on the bar
	var x;
	var y;
	for (x = 1; x < titleName.length; x++)
	{
		y = "menu" + x;
		goBar(y);
		backBar(y);
		goBar("menu" + mSelection);
	}
}

// create menu bar and display it
function menuSel()
{
	var x;
	document.write("<TABLE  BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#364C7E' BORDERCOLOR='#004080' ALIGN='left'>");
	for (x = 1; x < titleName.length; x++)
	{
		document.write("<TR>");
		document.write("<TD WIDTH='' ALIGN='center' ID='menu" + x + "'>");
		if (mSelection == x)
		{
			document.write("<FONT COLOR='#00FF00'><STRONG>" + titleName[x] + "</FONT></STRONG>");
		}
		else
		{
			document.write("<A HREF='#' CLASS='bar' onclick='navDir(" + x + ");'>");
			document.write("<STRONG>" + titleName[x] + "</STRONG>");
			document.write("</A>");
		}
		document.write("</TD>");
		document.write("</TR>");
	}
	document.write("</TABLE>");
}

// get users screen width & height
function setDisp()
{
	var winW = 0;
	var winH = 0;
	
	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=="Netscape")
		{
			winW = window.innerWidth - 40;
			winH = window.innerHeight - 40;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1)
		{
			winW = document.body.offsetWidth - 40;
			winH = document.body.offsetHeight - 40;
		}
	}
	document.getElementById("table1").style.width = winW;
	document.getElementById("table2").style.width = winW - 160;
	
}

// highlight buttons when mouse is over
function highlightButton(s)
{
	if ("INPUT"==event.srcElement.tagName)
	{
		event.srcElement.className=s
	}
}


