// GENERATE THE TOP NAV AND THEN REPLACE BUTTON COLOR ACCORDING TO CURRENT DIRECTORY
//alert ("this is topNav.js");

// some commonly used variables / strings of HTML
var oddNavElement_start = "\t\t<td width=\"147\" valign=\"top\"><a href=\"";
var evenNavElement_start = "\t\t<td width=\"145\" valign=\"top\"><a href=\"";
var navElement_end = " height=\"30\" border=\"0\"></a></td>\n";

// array of the image names and HTML code
topNav = new Array(5);
topNav[0] = oddNavElement_start + "/index.html\"><img src=\"/images/topNav_homeCold.gif\" width=\"147\"";
topNav[1] = evenNavElement_start + "/services/services.shtml\"><img src=\"/images/topNav_servicesCold.gif\" width=\"145\"";
topNav[2] = oddNavElement_start + "/STORE/\"><img src=\"/images/topNav_productsCold.gif\" width=\"147\"";
topNav[3] = evenNavElement_start + "/aboutUs/aboutUs.html\"><img src=\"/images/topNav_aboutUsCold.gif\" width=\"145\"";
topNav[4] = oddNavElement_start + "/contactUs/contactUs.shtml\"><img src=\"/images/topNav_contactCold.gif\" width=\"147\"";

var myDirMap;		// maps out the directory to element 
myDirMap = new Array();
myDirMap[0] = new Array( "com/index", 0 );
myDirMap[1] = new Array( "services", 1 );
myDirMap[2] = new Array( "product", 2 );
myDirMap[3] = new Array( "about", 3 );
myDirMap[4] = new Array( "contact", 4 );
myDirMap[5] = new Array( "net/index", 0 );

// okay, let's change out image so highlighted according to directory
// find out file name and then directory
var docLoc =  document.location;
var myURL = docLoc.toString ();
var myURLdirMatch = myURL.match(/\/([^\/]*)\/([^\/]*)$/);
var myURLdirectory = myURLdirMatch.toString();
var myDirectoryIndex;
var hotValue;

// according to directory, change out image
// figure out what directory i'm in
function checkDirectory () {
	myDirectoryIndex = -1;
	for ( var i = 0; i < myDirMap.length; i++ ) {
		if (( myURLdirectory.indexOf( myDirMap[i][0] )) != -1 ) {
			myDirectoryIndex = myDirMap[i][1];
		}
	}
	if ( myDirectoryIndex > -1 ) {
		changeToHot (myDirectoryIndex);
	}
}


//change image to Hot
function changeToHot(myDirectoryIndex) {
	hotValue = topNav[myDirectoryIndex].replace("Cold.gif", "Hot.gif");
	topNav[myDirectoryIndex] = hotValue;
}


// print out the nav
function printNav () {
	document.write ("<table align=\"center\" valign=\"top\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write ("<tr>");
		for (var i=0; i<topNav.length; i++) {
			document.write (topNav[i]);	
			document.write (navElement_end);
		}
	document.write ("</tr>");
	document.write ("</table>");
}

checkDirectory ();
printNav();





