// Arrays for the functions
var isMainCurrentPage = new Array(0, 0, 0, 0, 0, 0);
var NavImageName = new Array("home", "aboutus", "services", "education", "contact", "employ");
var isCurrentPage = new Array(0, 0, 0, 0, 0, 0);
var imageName;
var pagetype;
var cellSizes = new Array(100, 101, 100, 100, 100, 99);
var CurrentPage;

function mouseNavChange(index, change)
// Changes the Main Nav bar on rollovers
{
	// if the tab is on, we don't need a rollover
	if (isMainCurrentPage[index] == 1)
		return;
	
	// So we need a rollover.
	// First, build a string with the name of the image
	var fileName = "images/NEWNAV/nav_" + NavImageName[index];
	if (change == 0) { fileName += ".gif"; } else { fileName += "_over.gif"; }
	
	// Now change the appropriate image source to the new filename
	eval("document."+NavImageName[index]+".src=fileName;");
}

function mouseTabChange(index, change)
{
	// if the tab is on, we don't need a rollover
	if (isCurrentPage[index] == 1)
		return;
	
	// So we need a rollover.
	// First, build a string with the name of the image
	var fileName = "images/NEWNAV/"+CurrentPage+"_sub_" + imageName[index];
	if (change == 0) { fileName += ".gif"; } else { fileName += "_over.gif"; }

	// Now change the appropriate image source to the new filename
	eval("document."+imageName[index]+".src=fileName;");
}

function BuildNavMenu(SetToOn)
// Test function for building menus
{
	// Test
	switch (SetToOn)
	{	case 1: imageName = new Array("intro", "comphist", "team", "mission", "letter");
				 pagetype = new Array("htm", "htm", "htm", "htm", "htm");break;
		case 2: imageName = new Array("overview", "mobile", "promodel", "summary", "billing");
				 pagetype = new Array("htm", "htm", "htm", "htm", "cgi");break;
		case 3: imageName = new Array("overview", "patient", "physician", "testimonials", "links");
				 pagetype = new Array("htm", "htm", "cgi", "htm", "cgi");break;
		case 4: imageName = new Array("contactus", "request");
				 pagetype = new Array("htm", "htm");break;
		case 5: imageName = new Array("careers");
				 pagetype = new Array("cgi");break;
	}
	CurrentPage = NavImageName[SetToOn];

	// Start the Main Nav Bar
	if (SetToOn > 0) { isMainCurrentPage[SetToOn] = 1; }
	document.write("<table width=\"683px\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
	document.write("<tr><td width=\"40px\"><img src=\"images/NEWNAV/nav_left.gif\"></td>");
	document.write("<td width=\"100 px\">");
	document.write("<a href=\"index.htm\" onmouseover=\"mouseNavChange(0, 1)\" onmouseout=\"mouseNavChange(0, 0)\">");
	document.write("<img src=\"images/NEWNAV/nav_home.gif\" name=\"home\" border=\"0\"></a></td>");

	var type;
	// Main test portion
	for (var i=1; i<6; i++)
	{
		if (isMainCurrentPage[i] == 0)
		{	// This page is not active, add the href and mouseovers
			if (i == 5)
			{	type = "cgi"; }
			else
			{	type = "htm"; }
			var linkStr = "<a href=\""+NavImageName[i]+"."+type+"\" onmouseover=\"mouseNavChange("+i+", 1)\" onmouseout=\"mouseNavChange("+i+", 0)\">";
			var endStr = "</a></td>";
			var fileName = "images/NEWNAV/nav_" + NavImageName[i] + ".gif";
		} else
		{	// This page is active, do not add the href 
			var linkStr = "";
			var endStr = "</td>";
			var fileName = "images/NEWNAV/nav_" + NavImageName[i] + "_on.gif";
		}
		// Now print the item
		document.write("<td width=\""+cellSizes[i]+" px\">"+linkStr);
		document.write("<img src=\""+fileName+"\" name=\""+NavImageName[i]+"\" border=\"0\">");
		document.write(endStr);
	}
	
	// End the Main Nav Bar
	document.write("<td width=\"43px\"><img src=\"images/NEWNAV/nav_right.gif\"></td></tr>");
	document.write("</tr></table>");
}

function BuildSubMenu(SetToOn)
// This function will build the submenu navigation
{
	// Start the Sub Menu Section
	isCurrentPage[SetToOn] = 1;
	document.write("<table width=\"683px\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
	document.write("<td width=\"40 px\"></td>");

	// Main test portion
	for (var i=0; i<imageName.length; i++)
	{
		if (isCurrentPage[i] == 0)
		{	// This page is not active, add the href and mouseovers
			var linkStr = "<a href=\"";
			if (i == 0)
			{	linkStr +=CurrentPage+".htm\" ";	}
			else
			{	linkStr ="<a href=\""+imageName[i]+"."+pagetype[i]+"\" ";	}
			linkStr += "onmouseover=\"mouseTabChange("+i+", 1)\" onmouseout=\"mouseTabChange("+i+", 0)\">";
			var endStr ="</a></td>";
			var fileName ="images/NEWNAV/"+CurrentPage+"_sub_"+imageName[i]+".gif";
		} else
		{	// This page is active, do not add the href 
			var linkStr = "";
			var endStr = "</td>";
			var fileName = "images/NEWNAV/"+CurrentPage+"_sub_"+imageName[i]+"_on.gif";
		}
		// Now print the item
		document.write("<td width=\""+cellSizes[i]+" px\">"+linkStr);
		document.write("<img src=\""+fileName+"\" name=\""+imageName[i]+"\" border=\"0\">");
		document.write(endStr);
	}
	
	// End the Main Nav Bar
	for (i=0; i<(6-imageName.length); i++)
	{	document.write("<td>&nbsp;</td>");	}
	document.write("<td width=\"43px\"></td></tr>");
	document.write("</tr></table>");
}

function SubmitSearch()
// Currently unfinished
{	document.SearchForm.submit();
}
