// Contains common javascript functions for inspiredmuse.com
// (C) 2002 Scott Moore

// global variables
var thisSection = "home";
var relDir = "";
var thisSectionID = 0;
var menuImageOffset = 1;

var menuArray = ["services",
				"products",
				"clients",
				"resumes",
				"portfolio",
				"contact",
				"whyus",
				"home",
				"privacy",
				"copyright"];

var sectionMap = ["services/services.html",
				"products/products.html",
				"clients/clients.html",
				"resumes/resumes.html",
				"portfolio/portfolio.html",
				"contact/contact.html",
				"whyus/whyus_do.html",
				"index.html",
				"privacy.html",
				"copyright.html"];

// assigns global variables related to this page
function initialize(section, dir) {
	thisSection = section;
	relDir = dir;
	thisSectionID = getSectionID(section);
}

// determines section ID from section name
function getSectionID(sectionName) {
	var count = 0;
	while (sectionName != menuArray[count]) {
		count++;
	}		
	return count;
}

function buildLeftMenu() {
	var thisImage;
	var thisLink;
	if (thisSection == "services") {
		thisImage = relDir + "images/menu_services_HLT.jpg";
		thisLink = "#";
	} else {
		thisImage = relDir + "images/menu_services.jpg";
		thisLink = relDir + sectionMap[0];
	}		
	var htmlout = "<table width='107' height='280' cellpadding='0' cellspacing='0' border='0'>";
	var onmouseover = "menuSwap(\"menu_services\", 1);";
	var onmouseout = "swapBack(\"menu_services\", 1);";
	htmlout += "	<tr>";
	htmlout += "		<td width='107' height='39'><a href='" + thisLink + "' onmouseover='"+ onmouseover + "' onmouseout='" + onmouseout + "'><img src='" + thisImage + "' width='107' height='39'  border='0'></a></td>";
	htmlout += "	</tr>";
	document.write(htmlout);
	var count = 1;
	var imgOffset = 2;
	while (count < menuArray.length ) {
		var thisItem = menuArray[count];
		var thisLink = "";
		var thisImage = "";
		
		// put menu spacer in before the "Home" menu option
		if (thisItem == "home") {
			var spacehtml = "<tr>";
			spacehtml += "		<td width='107' height='51'><img src='" + relDir + "images/menu_spacer.jpg' width='107' height='51'  border='0'></td>";
			spacehtml += "	</tr>";
			document.write(spacehtml);
			imgOffset++;
		}
		
		// see if we need to use the HLT image
		if (count == thisSectionID) {
			thisImage = relDir + "images/menu_" + thisItem + "_HLT.jpg";
			thisLink = "#";
			onmouseover = "";
			onmouse = "";
		} else {  
			thisImage = relDir + "images/menu_" + thisItem + ".jpg";
			thisLink = relDir + sectionMap[count];
			var menuname = "menu_" + thisItem;
			onmouseover = "menuSwap(\"" + menuname + "\", " + imgOffset + ");";
			onmouseout = "swapBack(\"" + menuname + "\", " + imgOffset + ");";
		}
		var morehtml = "<tr>";
		morehtml += "		<td width='107' height='19'><a href='" + thisLink + "' onmouseover='"+ onmouseover + "' onmouseout='"+ onmouseout + "'><img src='" + thisImage + "' width='107' height='19'  border='0'></a></td>";
		morehtml += "	</tr>";
		document.write(morehtml);
		count++;
		imgOffset++;
	}
	// output menu bottom
	var menubottom = "	<tr>";
	menubottom += "		<td width='107' height='19'><img src='" + relDir + "images/menu_bottom.jpg' width='107' height='19'  border='0'></td>";
	menubottom += "	</tr>";
	menubottom += "</table>";
	document.write(menubottom);
	document.close();
	return true;
}

function writePageTitle() {
	var imageName = relDir + "images/page_title_" + thisSection + ".jpg";
	var outhtml = "<tr>";
	outhtml += "		<td height='29' width='121'><img src='" + imageName + "' height='29' width='121' border='0'></td>";
	outhtml += "		<td height='29' width='222'><img src='" + relDir + "images/top_right.jpg' height='29' width='222' border='0'></td>";
	outhtml += "	</tr>";
	document.write(outhtml);
	document.close();
	return true;
}	

function menuSwap(imgName, offset) {
	var imgSource = relDir + "images/" + imgName + "_HLT.jpg";
	document.images[offset].src = imgSource;
}

function swapBack(imgName, offset) {
	var imgSource = relDir + "images/" + imgName + ".jpg";
	document.images[offset].src = imgSource;
}

function clearEntry(matchString, element) {
	if (matchString.indexOf(element.value) > -1) {
		element.value = "";
	}
}

function isNetscape() {
	var browser = new String(navigator.appName);
	if (browser.indexOf("Netscape") >= 0) {
		return true;
	} else {
		return false;
	}
}