// JavaScript Document

function showMenu(menu){
	if (navigator.appName == "Netscape"){//compatible w/ NS6+
		document.getElementById(menu + "0").style.visibility = "visible";
		document.getElementById(menu + "1").style.visibility = "visible";
	} else if (navigator.appName == "Microsoft Internet Explorer"){
		document.all(menu + "0").style.visibility = "visible";
		document.all(menu + "1").style.visibility = "visible";
	}
}
function hideMenu(menu){
if (navigator.appName == "Netscape"){//compatible w/ NS6+
document.getElementById(menu + "0").style.visibility = "hidden";
document.getElementById(menu + "1").style.visibility = "hidden";
} else if (navigator.appName == "Microsoft Internet Explorer"){
document.all(menu + "0").style.visibility = "hidden";
document.all(menu + "1").style.visibility = "hidden";
	}
}

function overLink(id, css){
	//alert(css);
if (navigator.appName == "Netscape"){//compatible w/ NS6+
document.getElementById(id).className = "bgcol_" + css;
document.getElementById(id + "Link").className = "nav_over";
} else if (navigator.appName == "Microsoft Internet Explorer"){
document.all(id).className = "bgcol_" + css;
document.all(id + "Link").className = "nav_over";
	}
}

function outLink(id){
if (navigator.appName == "Netscape"){//compatible w/ NS6+
document.getElementById(id).className = "bgcol_none";
document.getElementById(id + "Link").className = "nav_out";
} else if (navigator.appName == "Microsoft Internet Explorer"){
document.all(id).className = "bgcol_none";
document.all(id + "Link").className = "nav_out";
	}
}

var navArr,navItm,id,itmArr,subItmArr,el,leftPos,topPos,ind,insetLft,elTop,subTopPos;
var imgNm,topPad,divX,divY,navId,menuWdth;

//multidim. array holding display text and links for top nav elements that have pulldown menus
navArr = new Array();
navArr[0]  = "company|company";//string before | is display text, string after is document name and nav id
navArr[0] += "^^history|history";//we'll simulate a multi. array by splitting at ^^
navArr[0] += "^^awards|awards";
navArr[0] += "^^facility|facility";
navArr[0] += "^^careers|careers";

navArr[1]  = "services|services";
navArr[1] += "^^photography alteration|photography_alteration";
navArr[1] += "^^prepress|prepress";
navArr[1] += "^^digital printing|digital_printing";
navArr[1] += "^^offset printing|offset_printing";
navArr[1] += "^^mailing|mailing";
navArr[1] += "^^fulfillment|fulfillment";
navArr[1] += "^^equipment list|equipment_list";

navArr[2]  = "clients|clients";
navArr[2] += "^^what they print|what_they_print";
navArr[2] += "^^why bennett?|why_bennett";
navArr[2] += "^^case studies|case_studies";

navArr[3]  = "customer service|customer_service";
navArr[3] += "^^request an estimate|request_an_estimate";
navArr[3] += "^^request a die-cut|request_brochure";
navArr[3] += "^^customer login|customer_login";
navArr[3] += "^^ftp site|ftp_site";
navArr[3] += "^^directions|directions";
navArr[3] += "^^contact us|contact_us";
navArr[3] += "^^mailing list sign up|mailing_list_sign_up";

navArr[4]  = "resources|resources_seminars";
navArr[4] += "^^tips &amp; updates|tips_updates";


ind = 2;//z index
for(var i = 0; i < navArr.length; i ++)
{
	itmArr = navArr[i].split("^^");//separate data sets in the array
	navId = navArr[i].substring(navArr[i].indexOf("|") + 1,navArr[i].indexOf("^^"));//return the first dataset identifier in each array item
	id     = navId + "Div";//hold the identifier for each div
	navId  = navId + "Nav";//hold the identifier for associated nav element
	//extract main menu text to insert in first div
		subItmArr = itmArr[0].split("|");//separate strings in the array
		txt       = subItmArr[0].toString();//first index in array is data set identifier
		elTop     = subItmArr[1].toString();//second index in array is data set identifier

	if (i == 0)//if we're on the first pulldown treat it differently
	{
		insetLft = 18;
	}
	else
	{
		insetLft = 10;		
	}
	if (navigator.appName == "Netscape"){//compatible w/ NS6+
		leftPos = document.getElementById(navId).offsetParent.offsetParent.offsetParent.offsetLeft + document.getElementById(navId).offsetLeft + "px";
		topPos  = document.getElementById(navId).offsetParent.offsetParent.offsetParent.offsetTop + "px";
		subTopPos  = document.getElementById(navId).offsetParent.offsetParent.offsetParent.offsetTop + document.getElementById(navId).offsetParent.offsetParent.offsetParent.offsetHeight  - 1 + "px";
} else if (navigator.appName == "Microsoft Internet Explorer"){
		leftPos = document.all(navId).offsetParent.offsetParent.offsetParent.offsetLeft + document.all(navId).offsetLeft + "px";
		topPos  = document.all(navId).offsetParent.offsetParent.offsetParent.offsetTop + "px";
		subTopPos  = document.all(navId).offsetParent.offsetParent.offsetParent.offsetTop + document.all(navId).offsetParent.offsetParent.offsetParent.offsetHeight - 1 + "px";
}
	
		document.write("<div id=\"" + id + "0\" name=\"" + id + "0\" style=\"position:absolute; z-index: " + ind + 1 + "; left:" + leftPos + "; top:" + topPos + "; visibility:hidden; cursor: pointer;\" onmouseover=\"javascript:showMenu('" + id + "')\" onmouseout=\"javascript:hideMenu('" + id + "')\" align=\"left\">");
		document.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ffffff\">");
		document.write("<tr>");
		document.write("<td class=\"border\" colspan=\"5\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" /></td>");
		document.write("</tr>");
		document.write("<tr onclick=\"javascript:location.href='" + elTop + ".aspx'\">");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"1\" height=\"25\" /></td>");
		document.write("<td><img src=\"images/spacer.gif\" width=\"" + insetLft + "\" height=\"1\" /></td>");
		document.write("<td align=\"left\" class=\"nav color_" + elTop + "\">" + txt + "</td>");
		document.write("<td><img src=\"images/spacer.gif\" width=\"10\" height=\"1\" /></td>");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" /></td>");
		document.write("</tr>");
		document.write("<tr>");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" /></td>");
		document.write("<td colspan=\"3\" id=\"" + id + "0TdWdth\" name=\"" + id + "0TdWdth\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" /></td>");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" /></td>");
		document.write("</tr>");
		document.write("</table>");
		document.write("</div>");
		//find out how much to make the right side of sub menu stick out, it at least will be menuWdth
		//if string is longer in submenu than menuWdth, table will adjust according to string
		menuWdth = document.getElementById(id + "0TdWdth").offsetParent.offsetParent.offsetWidth - insetLft;
		document.write("<div id=\"" + id + "1\" name=\"" + id + "1\" style=\"position:absolute; z-index: " + ind + "; left:" + leftPos + "; top:" + subTopPos + "; visibility:hidden; cursor: pointer;\" onmouseover=\"javascript:showMenu('" + id + "')\" onmouseout=\"javascript:hideMenu('" + id + "')\" align=\"left\">");
		document.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ffffff\">");
		document.write("<tr>");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" /></td>");
		document.write("<td><img src=\"images/spacer.gif\" width=\"" + insetLft + "\" height=\"1\" /></td>");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"" + menuWdth + "\" height=\"1\" /></td>");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"10\" height=\"1\" /></td>");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" /></td>");
		document.write("</tr>");
	for (var j = 1; j < itmArr.length; j ++) 
	{
		subItmArr = itmArr[j].split("|");//separate strings in the array
		txt       = subItmArr[0].toString();//first index in array is data set identifier
		el        = subItmArr[1].toString();//second index in array is data set identifier

		document.write("<tr id=\"" + el + "\" name=\"" + el + "\" onclick=\"javascript:location.href='" + el + ".aspx'\" onmouseover=\"javascript:overLink('" + el + "', '" + elTop + "')\" onmouseout=\"javascript:outLink('" + el + "')\">");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"1\" height=\"18\" /></td>");
		document.write("<td align=\"right\" class=\"nav_over\">+&nbsp;</td>");
		document.write("<td align=\"left\" id=\"" + el + "Link\" name=\"" + el + "Link\" class=\"nav_out\">" + txt + "</td>");
		document.write("<td></td>");
		document.write("<td class=\"border\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" /></td>");
		document.write("</tr>");
	}
	document.write("<tr>");
	document.write("<td class=\"border\" colspan=\"7\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" /></td>");
	document.write("</tr>");
	document.write("</table>");
	document.write("</div>");
	ind = ind + 2;
}

//this is called at the html <body> element onresize
//have to reposition the menus whenever the browser window is scaled
function PositionMenus()
{
	for(var i = 0; i < navArr.length; i ++)
	{
		itmArr = navArr[i].split("^^");//separate data sets in the array
		navId = navArr[i].substring(navArr[i].indexOf("|") + 1,navArr[i].indexOf("^^"));//return the first dataset identifier in each array item
		id     = navId + "Div";//hold the identifier for each div
		navId  = navId + "Nav";//hold the identifier for associated nav element
		if (navigator.appName == "Netscape"){//compatible w/ NS6+
			leftPos = document.getElementById(navId).offsetParent.offsetParent.offsetParent.offsetLeft + document.getElementById(navId).offsetLeft + "px";
			topPos  = document.getElementById(navId).offsetParent.offsetParent.offsetParent.offsetTop + "px";
			subTopPos  = document.getElementById(navId).offsetParent.offsetParent.offsetParent.offsetTop + document.getElementById(navId).offsetParent.offsetParent.offsetParent.offsetHeight  - 1 + "px";
			document.getElementById(id + "0").style.left = leftPos;
			document.getElementById(id + "0").style.top  = topPos;
			document.getElementById(id + "1").style.left = leftPos;
			document.getElementById(id + "1").style.top  = subTopPos;
		} else if (navigator.appName == "Microsoft Internet Explorer"){
			leftPos = document.all(navId).offsetParent.offsetParent.offsetParent.offsetLeft + document.all(navId).offsetLeft + "px";
			topPos  = document.all(navId).offsetParent.offsetParent.offsetParent.offsetTop + "px";
			subTopPos  = document.all(navId).offsetParent.offsetParent.offsetParent.offsetTop + document.all(navId).offsetParent.offsetParent.offsetParent.offsetHeight  - 1 + "px";
			document.all(id + "0").style.left = leftPos;
			document.all(id + "0").style.top  = topPos;
			document.all(id + "1").style.left = leftPos;
			document.all(id + "1").style.top  = subTopPos;
		}
	}
}

