// Contains common javascript functions for scottymo.com
// (C) 2002 Scott Moore

// global variables
var thisSection = "Home";
var relDir = "";
var thisSectionID = 0;

var menuArray = ["hdr_menu_home",
				"hdr_menu_resume",
				"hdr_menu_music",
				"hdr_menu_poetry",
				"hdr_menu_travels",
				"hdr_menu_events"];
var menuImageOffset = 1;

var sectionArray = ["Home",
				"Resume",
				"Music",
				"Poetry",
				"Travels",
				"Events"];

var sectionMap = ["index.html",
				"resume/resume.html",
				"music/music.html",
				"poetry/poetry.html",
				"travels/travels.html",
				"events/events.html"];

// assigns global variables related to this page
function initialize(section, dir) {
	thisSection = section;
	relDir = dir;
	thisSectionID = getSectionID(thisSection);
}

// determines section ID from section name
function getSectionID(sectionName) {
	var count = 0;
	while (sectionName != sectionArray[count]) {
		count++;
	}		
	return count;
}


function buildHeader() {
	var blah = "<td><table width='700' height='85' border='0' cellspacing='0' cellpadding='0' align='center'>";
	blah += "<tr>";
	blah += "	<td width='700' height='35' colspan='2'><img src='" + relDir + "images/header_top.gif' width='700' height='35' border='0'></td>";
	blah += "</tr>";			 
	blah += "<tr>";			 
	blah += "	<td width='245' height='50'><img src='" + relDir + "images/header_left.gif' width='245' height='50' border='0'></td>";
	blah += "	<td width='455' height='50'>";
	blah += "		<table width='455' height='50' border='0' cellspacing='0' cellpadding='0' align='center'>";
	blah += "			<tr>";
	blah += "				<td width='70'><img src='" + relDir + "images/hdr_menu_left.gif' width='70' height='30' border='0'></td>";
	document.writeln(blah);
	
	// iterate through each menu item
	var menuID = 0;
	while (menuID < menuArray.length) {
		var imgFile = relDir + "images/" + menuArray[menuID];
		var hasPurpleLines = false;
		var linkOpenTag = "";
		var linkCloseTag = "";
		if (menuID == thisSectionID) {
			imgFile += "_ON.gif";
			linkOpenTag += "<a href='" + relDir + sectionMap[menuID] + "'>";
			linkCloseTag += "</a>";
		}
		else {
			if (menuID < thisSectionID) {
				imgFile += "_PRP.gif";
				hasPurpleLines = true;
			}
			else {
				imgFile += ".gif";
			}
			linkOpenTag += "<a href='" + relDir + sectionMap[menuID] + "' onmouseover='menuSwap(" + menuID + ", true, " + hasPurpleLines + ")' ";
			linkOpenTag += "onmouseout='menuSwap(" + menuID + ", false, " + hasPurpleLines + ")'>";
			linkCloseTag += "</a>";
		}
		var linkFile = relDir + sectionMap[menuID];
		var bloop = "<td width='60'>" + linkOpenTag;
		bloop += "<img src='" + imgFile + "' width='60' height='30' alt='' border='0'>";
		bloop += linkCloseTag + "</td>";

		document.writeln(bloop);
		menuID++;
	}

	var grok = "			<td width='25'><img src='" + relDir + "images/hdr_menu_right.gif' width='25' height='50' border='0'></td>";
	grok += "			</tr>";
	grok += "		</table></td></tr>";
	grok += "	</table></td>";
	document.writeln(grok);
	document.close();

	return true;
}

function menuSwap(menuID, highlight, purpleLines) {
	var imgSource = relDir + "images/" + menuArray[menuID];
	
	if (highlight) {
		imgSource += "_HLT";
	}
	if (purpleLines) {
		imgSource += "_PRP";
	}
	imgSource += ".gif";

	document.images[menuID + 3].src = imgSource;
	return true;
}

function buildFooter() {
	var blah = "<td width='700' height='85' background='" + relDir + "images/footer.gif'>";
	blah +=	"	<table width='700' height='85' border='0' cellspacing='0' cellpadding='0' align='center'>";
	blah += "	<tr>";
	blah += "		<td width='150' height='20'> &nbsp; </td>";
	blah += "		<td align='center' background=''> <a class='bottomMenu' href='javascript:history.back();'> Back </a> </td>";
	blah += "		<td align='center' background=''> | </td>";
	blah += "		<td align='center' background=''> <a class='bottomMenu' href='#'> Top </a> </td>";
	blah += "		<td align='center' background=''> | </td>";
	blah += "		<td align='center' background=''> <a class='bottomMenu' href='/index.html'> Home </a> </td>";
	blah += "		<td align='center' background=''> | </td>";
	blah += "		<td align='left' background=''> &nbsp; <a class='bottomMenu' href='mailto:scott@scottymo.com'> Contact: scott@scottymo.com </a> </td>";
	blah += "	</tr>";
	blah += "	<tr align='center'>";
	blah += "		<td class='copyright' height='15' colspan='8' background=''> &copy; 2002 Scott R. Moore. All rights reserved. </td>";
	blah += "	</tr>";
	blah += "	<tr><td colspan='8' height='50' background=''>&nbsp;</td></tr>";
	blah += "</table></td>";			 
	document.writeln(blah);
	document.close();

	return true;
}
