// ****************************************
// *  Configure button options
// ****************************************

var button_count = 9;				// select:	# of buttons
var button_type = "text";			// select: 	"text" or "image"

var text_style = "navigation";			// assign css anchor style to be applied to the text_array[]
var text_array = new Array(button_count);	// assign wording for text buttons
text_array[0] = "HOME";				
text_array[1] = "COMPANY";							
text_array[2] = "SERVICES";
text_array[3] = "SKILLS";
text_array[4] = "PORTFOLIO";
text_array[5] = "AFFILIATES";
text_array[6] = "CONTACT";
text_array[7] = "IMAGE";
text_array[8] = "LOGO";
text_array[9] = "WEB";

var image_path = "./images/";			// enter the relative path for the location of the images
var image_type = ".JPG";			// select: 	".gif" or ".jpg"
var mouse_events = 2;				// select:	1 (no mouseover, no mousedown)
																//	  			2 (with mouseover, no mousedown)
var mouseover_array = new Array(button_count);	// assign special JavaScript for button mouseovers
mouseover_array[0] = "hideSubNav(7); hideSubNav(8); hideSubNav(9);";			
mouseover_array[1] = "hideSubNav(7); hideSubNav(8); hideSubNav(9);";							
mouseover_array[2] = "hideSubNav(7); hideSubNav(8); hideSubNav(9);";
mouseover_array[3] = "hideSubNav(7); hideSubNav(8); hideSubNav(9);";
mouseover_array[4] = "clearInterval(task); showSubNav(7,text_array[7]); showSubNav(8,text_array[8]); showSubNav(9,text_array[9]);";
mouseover_array[5] = "hideSubNav(7); hideSubNav(8); hideSubNav(9);";
mouseover_array[6] = "hideSubNav(7); hideSubNav(8); hideSubNav(9);";
mouseover_array[7] = "";
mouseover_array[8] = "";
mouseover_array[9] = "";

if (button_type == "image") {

	// ****************************************
	// *  Preload button images
	// ****************************************

	var button = new Array(button_count);

	for (i = 1; i <= button_count; i++) {
		button[i] = new Array(mouse_events);
	}

	for (x = 1; x <= button_count; x++) {
		for (y = 0; y < mouse_events; y++) {
			button[x][y] = new Image();
			button[x][y].src = image_path + "button" + x + "_" + y + image_type;
		}
	}

	// ****************************************
	// *  Write button images to page
	// ****************************************

	for (x = 1; x <= button_count; x++) {

		obj = "document.imgButton" + x + ".src";
		button_string = "<div id='button" + x + "'><a href='index" + x + ".htm '";

		if (mouse_events > 1) {
			button_string += "onmouseover = '" + obj + " = button[" + x + "][1].src '" +
					 "onmouseout = '" + obj + " = button[" + x + "][0].src '";
		}

		if (mouse_events > 2) {
			button_string += "onmousedown = '" + obj + " = button[" + x + "][2].src '";
		}

		button_string +="><img src='" + button[x][0].src + "' border='0' name='imgButton" + x + "'></a></div>";

		document.write(button_string);
	}

} else {

	// ****************************************
	// *  Write text buttons to page
	// ****************************************


	// Used to 'disable' the current button selection.
	for (i = 0; i <= button_count; i++) {
		document.write("<div id='button" + i + "'>");

		if(i == 4 && getPageNum() >= 7) {
			document.write(text_array[i]);
		} else if(i == 4) {
			document.write("<a class='" + text_style + "' href='#nowhere' onmouseover='" + mouseover_array[i] + "'>");
			document.write(text_array[i]);
			document.write("</a>");
		} else if (getPageNum() >= 7) {
			if(i == getPageNum()) {
				document.write(text_array[i]);
			} else {
				if (i == 0 ) {
					document.write("<a class='" + text_style + "' href='index.htm' onmouseover='" + mouseover_array[i] + "'>");
				} else {
					document.write("<a class='" + text_style + "' href='index" + i + ".htm' onmouseover='" + mouseover_array[i] + "'>");
				}
				document.write(text_array[i]);
				document.write("</a>");
			}
		} else if (i >= 7) {
			document.write(" ");
		} else if (i != getPageNum() && getPageNum() < 7) {
			//alert("pageNum = " + getPageNum() + "\ni = " + i);
			if (i == 0 ) {
				document.write("<a class='" + text_style + "' href='index.htm' onmouseover='" + mouseover_array[i] + "'>");
			} else {
				document.write("<a class='" + text_style + "' href='index" + i + ".htm' onmouseover='" + mouseover_array[i] + "'>");
			}
			document.write(text_array[i]);
			document.write("</a>");
		} else {
			document.write(text_array[i]);
		}

		document.write("</div>");
	}

}

// ****************************************
// *  Custom functions
// *  ** Add nav functions here **
// ****************************************

var task = 0;

function showSubNav(button_no, button_text) {
	if (getPageNum() == button_no) {
		document.getElementById('button' + button_no).innerHTML = button_text;
	} else {
		document.getElementById('button' + button_no).innerHTML = 
			"<a class='navigation' href='index" + button_no + ".htm' " +  
			"onmouseout='hideSubNavOnTimeout();' " + 
			"onmouseover='clearInterval(task);'>" + 
			button_text + "</a>";
	}
}

function hideSubNav(button_no) {
	//alert(getPageNum());
	if (getPageNum() < 7) {
		document.getElementById('button' + button_no).innerHTML = " ";
	}
}

function hideSubNavOnTimeout() {
	task = setInterval("hideSubNav(7); hideSubNav(8); hideSubNav(9);", 500);
}
