
arrowOn		= new Image;	arrowOn.src		= "../images/nav/arrowOn.gif";
arrowOff	= new Image;	arrowOff.src	= "../images/nav/arrowOff.gif";
arrowDown	= new Image;	arrowDown.src	= "../images/nav/arrowDown.gif";

ns = (document.layers)? true:false
ie = (document.all)? true:false
ns6 = (navigator.appName == "Netscape" && document.getElementById)? true:false
winIE5 = false;
var browserString = navigator.appVersion;
if (navigator.userAgent.indexOf("Win") > -1 && navigator.appName == "Microsoft Internet Explorer"){
	if (parseInt(browserString.charAt(22)) < 6){
		winIE5 = true;
	}
}
macIE = false;
macNS = false;
var browserString = navigator.appVersion;
/*if( navigator.userAgent.indexOf("Mac") > -1 ){
	alert(navigator.userAgent);
}*/
if (navigator.userAgent.indexOf("Mac") > -1 && navigator.appName == "Microsoft Internet Explorer"){
	macIE = true;
	//alert(macIE);
}else if(navigator.userAgent.indexOf("Mac") > -1 && navigator.appName != "Microsoft Internet Explorer"){
	macNS = true;
}
function hide(id){
	if (ns) document.layers[id].visibility = "hide"
	if (ns6){
		var obj = eval("document.getElementById('" + id + "')")
		obj.style.visibility = "hidden"
	}
	else if (ie) document.all[id].style.visibility = "hidden"
}
function show(id){
	if (ns) document.layers[id].visibility = "show"
	if (ns6){
		var obj = eval("document.getElementById('" + id + "')")
		obj.style.visibility = "visible"
	}
	else if (ie) document.all[id].style.visibility = "visible"
}
function findPosX(obj){
	var curleft = 0;
	if (document.getElementById || document.all){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
		//alert(curleft);
		return curleft;
	}
}
function findPosY(obj){
	var curtop = 0;
	if (document.getElementById || document.all){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
		return curtop;
	}else{
		curtop += obj.y;
		return curtop;
	}
}

function doMainNav(theIndex){
	//alert (theIndex);
	for(i = 1; i <= (mainNavs.length - 1); i ++){
		if(i == theIndex){
			show("menu" + i);
			show("bigHide");
			show("bigHide2");
			for(m = 1; m <= totalSubSubs; m ++){
				hide("menuSub" + m);
			}
		var obj = eval("document.getElementById('butID" + i + "')")
		obj.style.backgroundColor='8C034E';
		obj.style.color = 'ffffff';
		}else{
			hide("menu" + i);
			var obj = eval("document.getElementById('butID" + i + "')")
			obj.style.backgroundColor='';
			obj.style.color = '000000';
		}
	}
	if(theIndex == -1){
		for(m = 1; m <= totalSubSubs; m ++){
			hide("menuSub" + m);
		}
		doSubNav(-1, 1, -1, -1);
		for(m = 1; m <= totalSubSubSubs; m ++){
			hide("menuSubSub" + m);
		}
		doSubSubNav(-1, 1, -1, -1);
		hide("bigHide");
		hide("bigHide2");
	}
}

function mainNavOBJ(theWidth, displayText, whichType, theLink){
	this.theWidth		= theWidth;
	this.displayText	= displayText;
	this.whichType		= whichType;
	this.theLink		= theLink;
}

masterTop = 72;

mainNavs = new Array();
	mainNavs[1] = new menuItem('PRODUCTS','../nutfield/products.asp');
	mainNavs[2] = new menuItem('CONTACT US','../nutfield/contact.asp');
	mainNavs[3] = new menuItem('DISTRIBUTORS','../nutfield/distributors.asp');
	mainNavs[4] = new menuItem('DOWNLOADS_SPECS','../nutfield/downloads.asp');
	mainNavs[5] = new menuItem('ABOUT US','../nutfield/about.asp');
	mainNavs[6] = new menuItem('CLIENT EXTRANET','../nutfield/extranet.asp');

function writeMainNav(){
	outMainHTML = "";
	outMainHTML += "<table cellpadding=0 cellspacing=0 border=0><tr>"; // width=\"240\"

	if( macIE ){
		//alert(macIE);
		fontTag = "<font style=\"font-size:9px;\">";
		fontTagC = "</font>";
	}else{
		fontTag = "";
		fontTagC = "";
	}

	for(i = 1; i <= (mainNavs.length - 1); i ++){
		outMainHTML +="<td bgcolor=\"#666666\" width=\"1\"><img src=\"../images/spacer.gif\" width=1 border=0 height=17 align=\"bottom\">";
		outMainHTML += "<td class=\"Nav\" id=\"butID" + i + "\" nowrap onMouseOver=\"this.style.backgroundColor='#8C034E';doMainNav(" + i + ");\" onClick=\"location='" + mainNavs[i].goLink + "';\">" + fontTag +  mainNavs[i].displayText.replace("_","/") + fontTagC + "</td>";
	}
	outMainHTML += "</tr></table>";
	//alert(outMainHTML);
	document.write(outMainHTML);
}

function doSubNav(ele, state, subIndex, rowIndex){
	if(state > 0){
		//alert(ele.id);
		//ele.style.backgroundColor = '778998';
		//ele.style.color = '000000';
		for(m = 1; m < rowCount; m ++){
			if(m == rowIndex){
				if(ns6){
					var obj = eval("document.getElementById('row" + m + "')")
					obj.style.backgroundColor = '1C0792';
					obj.style.color = 'ffffff';
				}else if(ie){
					if(!macIE){
						document.all["row" + m].style.backgroundColor = '1C0792';//#8C034E
					}
					document.all["row" + m].style.color = 'ffffff';
				}
			}else{
				if(ns6){
					var obj = eval("document.getElementById('row" + m + "')")
					obj.style.backgroundColor = '8C034E';
					obj.style.color = 'ffffff';
				}else if(ie){
					if(!macIE){
						document.all["row" + m].style.backgroundColor = '8C034E';
					}
					document.all["row" + m].style.color = 'ffffff';
				}
			}
		}
		for(k = 1; k <= totalSubSubs; k ++){
			if(k == subIndex){
				show("menuSub" + k);
			}else{
				hide("menuSub" + k);
			}
		}
		for(k = 1; k <= totalSubSubSubs; k ++){
			hide("menuSubSub" + k);
		}
	}/*else{
		ele.style.backgroundColor = '19344C';
		ele.style.color = 'ffffff';
	}*/
}
function doSubSubNav(ele, state, subIndex, rowIndex){
	if(state > 0){
		//ele.style.backgroundColor = '2E6FAF';
		//ele.style.color = 'ffffff';
		//alert(rowIndex);
		for(b = 1; b < rowSubCount; b ++){
			if(b == rowIndex){
				if(ns6){
					var obj = eval("document.getElementById('rowSub" + b + "')")
					obj.style.backgroundColor = '#16076A';
					obj.style.color = 'ffffff';
				}else if(ie){
					if(!macIE){
						document.all["rowSub" + b].style.backgroundColor = '#16076A';
					}
					document.all["rowSub" + b].style.color = 'ffffff';
				}
			}else{
				if(ns6){
					var obj = eval("document.getElementById('rowSub" + b + "')")
					obj.style.backgroundColor = '#1C0792';
					obj.style.color = 'ffffff';
				}else if(ie){
					if(!macIE){
						document.all["rowSub" + b].style.backgroundColor = '#1C0792';
					}
					document.all["rowSub" + b].style.color = 'ffffff';
				}
			}
		}
		for(k = 1; k <= totalSubSubSubs; k ++){
			if(k == subIndex){
				show("menuSubSub" + k);
			}else{
				hide("menuSubSub" + k);
			}
		}
	}/*else{
		ele.style.backgroundColor = '778998';
		ele.style.color = '000000';
	}*/
}

function menuItem(displayText,goLink,hasSub,subIndex,topPos,leftPos){
	this.displayText = displayText;
	this.goLink = goLink;
	this.hasSub = hasSub;
	this.subIndex = subIndex;
	this.topPos = topPos;
	this.leftPos = leftPos;
}
sub1 = new Array();
	sub1[0] = new menuItem('SCAN HEADS','../nutfield/scanheads.asp',1,1);
	sub1[1] = new menuItem('GALVANOMETERS','../nutfield/galvanometers.asp');
	//sub1[2] = new menuItem('RESONANT','../nutfield/resonant.asp');
	sub1[2] = new menuItem('LASER/SCANNER CONTROL ELECTRONICS','../nutfield/electronics.asp');
	sub1[3] = new menuItem('LASER/SCANNER CONTROL SOFTWARE','../software/software.asp');
	//sub1[5] = new menuItem('LASERS','../lasers/cypherV10.asp');
	sub1[4] = new menuItem('SCAN MIRRORS','../nutfield/mirrors.asp');
sub2 = new Array();
	sub2[0] = new menuItem('DIRECTIONS','../nutfield/locations.asp');
	sub2[1] = new menuItem('SALES CONTACTS','../nutfield/sales.asp');
	sub2[2] = new menuItem('REQUEST INFORMATION','../nutfield/request.asp');
	sub2[3] = new menuItem('REPAIR REQUEST', '../nutfield/service.asp');
sub3 = new Array();
sub4 = new Array();
	sub4[0] = new menuItem('SOFTWARE DOWNLOAD', '../nutfield/software_downloads.asp');
	sub4[1] = new menuItem('SPEC’S/DRAWINGS', '../nutfield/specs_drawings.asp');
	sub4[2] = new menuItem('MANUALS', '../nutfield/manuals.asp');
	sub4[3] = new menuItem('APPLICATION NOTES', '../nutfield/app_notes.asp');
	sub4[4] = new menuItem('NTI FORMS', '../nutfield/nti_forms.asp');
	sub4[5] = new menuItem('HELPFUL INFORMATION', '../nutfield/the_hole.asp');
sub5 = new Array();
	sub5[0] = new menuItem('COMPANY OVERVIEW','../nutfield/overview.asp');
	sub5[1] = new menuItem('APPLICATIONS','../nutfield/applications.asp');
	sub5[2] = new menuItem('QUALITY','../nutfield/quality.asp');
	sub5[3] = new menuItem('TERMS & CONDITIONS','../nutfield/terms.asp');
sub6 = new Array();

totalSubSubs = 1;

subsub1 = new Array();
	subsub1[0] = new menuItem("PACKAGED SCAN HEADS","../nutfield/pscanheads.asp",0,0,71,568);
	subsub1[1] = new menuItem("X/Y OPEN FRAME SCAN HEADS","../nutfield/frameheads.asp",0,0,71,568);
totalSubSubSubs = 0;
/*
subsubsub1 = new Array();
	subsubsub1[0] = new menuItem("NOT USING","../programs/showCategories.asp?library=1",0,0,128,440);
	subsubsub1[1] = new menuItem("Information/Computer Security","../programs/showCategories.asp?library=2");
	subsubsub1[2] = new menuItem("Business Continuity/Disaster Recovery","../programs/showCategories.asp?library=3");
*/


rowCount = 1;
rowSubCount = 1;
function writeLayers(){
	outHTML = "";
	findFirstLeftHandPoint=2000;
	menuWith = 150;//120;
	if(ns){
		outHTML += "<div id=\"mud\" style=\"position:absolute;left:0px;top:0px;visibility:hidden;z-index:0\"></div>"
	}
	for(j = 1; j <= (mainNavs.length - 1); j ++){
		currentMenu = eval("sub" + j);
		theLength = currentMenu.length;
		n = j;
		//alert(n);
		if(ie){
			anchorX = findPosX(document.all("butID" + n));
			anchorY = findPosY(document.all("butID" + n));
			//alert(anchorX);
			//alert(anchorY);
			//theClass = "navSub";
		}else if(ns6){
			anchorX = findPosX(document.getElementById("butID" + n));
			//theClass = "navSub";
		}else if(ns){
			anchorX = document.layers["butID" + n].pageX;
			//theClass = "navSubNS4";
		}
		if (anchorX < findFirstLeftHandPoint)
		{
			findFirstLeftHandPoint=anchorX;
		}
		outHTML += "<div id=\"menu" + j + "\" style=\"position:absolute; top:" + masterTop + "px; left:" + anchorX + "px; visibility:hidden; z-index:100;\">";
		if(theLength > 0){
			outHTML += "<table cellpadding=0 cellspacing=0 border=0 width=160>";
			for(z = 0; z < theLength; z ++){
				if(ns){
					theLink = "<a href=\"" + currentMenu[z].goLink + "\">" + currentMenu[z].displayText + "</a>";
					theClass = "subNavNS";
				}else{
					theLink = currentMenu[z].displayText;
					theClass = "subNav";
				}
				if(currentMenu[z].hasSub != null){
					//theArrow = "<img src=\"../images/spacer.gif\" width=" + currentMenu[z].arrowWidth + " height=1 align='absmiddle'><img src=\"../images/nav/arrowSub.gif\" width=3 height=5>";
					theArrow = "<img src=\"../images/nav/arrowNav.gif\" width=5 height=5>";
				}else{
					theArrow = "<img src=\"../images/spacer.gif\" width=5 height=5>";
				}
				if(currentMenu[z].hasSub != null){
					sendSubIndex = currentMenu[z].subIndex;
				}else{
					sendSubIndex = -1;
				}
				outHTML += "<tr class=\"" + theClass + "\" onMouseOver=\"doSubNav(this,1," + sendSubIndex + "," + rowCount + ");\" onMouseOut=\"//doSubNav(this,0);\" id=\"row" + rowCount + "\"><td width=6><img src=\"../images/spacer.gif\" width=6 height=18></td><td onClick=\"parent.location='" + currentMenu[z].goLink + "';\">" + theLink + "</td><td width=7>" + theArrow + "</td></tr>";
				outHTML += "<tr><td width=" + mainNavs[j].theWidth + " bgcolor=\"#666666\" colspan=3><img src=\"../images/spacer.gif\" width=1 height=1></td></tr>";
				rowCount ++;
			}
			outHTML += "</table>";
		}
		outHTML += "</div>";
	}
	outHTML += "<div id=\"bigHide\" style=\"position:absolute;left:0px;top:" + masterTop + "px;visibility:hidden;z-index:1;\"><a href=\"#\" onMouseOver=\"doMainNav(-1, 'Off')\"><img src=\"../images/spacer.gif\" width=766 height=300 border=0></a></div>";

	outHTML += "<div id=\"bigHide2\" style=\"position:absolute;left:0px;top:0px;visibility:hidden;z-index:1;\"><a href=\"#\" onMouseOver=\"doMainNav(-1, 'Off')\"><img src=\"../images/spacer.gif\" width=766 height=50 border=0></a></div>";

	//document.write(outHTML);
	//loaded = true;
	writeSubLayers(findFirstLeftHandPoint);
	//alert(outHTML);
}
function writeSubLayers(anchorX){
	anchorX+=160;
	for(a = 1; a <= totalSubSubs; a ++){
		currentMenu = eval("subsub" + a);
		theLength = currentMenu.length;
		outHTML += "<div id=\"menuSub" + a + "\" style=\"position:absolute; top:" + currentMenu[0].topPos + "px; left:" + anchorX + "px; visibility:hidden; z-index:100;\">";
		
		//outHTML += "<div id=\"menuSub" + a + "\" style=\"position:absolute; top:" + currentMenu[0].topPos + "px; left:" + currentMenu[0].leftPos + "px; visibility:hidden; z-index:100;\">";
		outHTML += "<table cellpadding=0 cellspacing=0 border=0 width=135>";
		outHTML += "<tr><td width=130 bgcolor=\"#4C7299\" colspan=3><img src=\"../images/spacer.gif\" width=1 height=1></td></tr>";
			for(z = 0; z < theLength; z ++){
				if(ns){
					theLink = "<a href=\"" + currentMenu[z].goLink + "\">" + currentMenu[z].displayText + "</a>";
					theClass = "subsubNavNS";
				}else{
					theLink = currentMenu[z].displayText;
					theClass = "subsubNav";
				}
				if(currentMenu[z].hasSub != null){
					if(currentMenu[z].hasSub == 1){
						theArrow = "<img src=\"../images/nav/arrowNav.gif\" width=5 height=8>";
					}else{
						theArrow = "<img src=\"../images/spacer.gif\" width=5 height=5>";
					}
					
				}else{
					theArrow = "<img src=\"../images/spacer.gif\" width=5 height=5>";
				}
				if(currentMenu[z].hasSub != null){
					sendSubIndex = currentMenu[z].subIndex;
				}else{
					sendSubIndex = -1;
				}
				outHTML += "<tr class=\"" + theClass + "\" onMouseOver=\"doSubSubNav(this,1," + sendSubIndex + "," + rowSubCount + ");\" onMouseOut=\"//doSubSubNav(this,0);\" id=\"rowSub" + rowSubCount + "\"><td width=6><img src=\"../images/spacer.gif\" width=6 height=6></td><td onClick=\"parent.location='" + currentMenu[z].goLink + "';\" width=122>" + theLink + "</td><td width=7>" + theArrow + "</td></tr>";
				outHTML += "<tr><td width=130 bgcolor=\"#666666\" colspan=3><img src=\"../images/spacer.gif\" width=1 height=1></td></tr>";
				rowSubCount ++;
			}
			outHTML += "</table>";
		outHTML += "</div>";
	}
	//document.write(outHTML);
	//loaded = true;
	writeSubSubLayers();
}
function writeSubSubLayers(){
	for(a = 1; a <= totalSubSubSubs; a ++){
		currentMenu = eval("subsubsub" + a);
		theLength = currentMenu.length;
		outHTML += "<div id=\"menuSubSub" + a + "\" style=\"position:absolute; top:" + currentMenu[0].topPos + "px; left:" + currentMenu[0].leftPos + "px; visibility:hidden; z-index:100;\">";
		outHTML += "<table cellpadding=0 cellspacing=0 border=0 width=160>";
		outHTML += "<tr><td width=160 bgcolor=\"ffffff\" colspan=2><img src=\"../images/spacer.gif\" width=1 height=1></td></tr>";
			for(z = 0; z < theLength; z ++){
				if(ns){
					theLink = "<a href=\"" + currentMenu[z].goLink + "\">" + currentMenu[z].displayText + "</a>";
					theClass = "subsubsubNavNS";
				}else{
					theLink = currentMenu[z].displayText;
					theClass = "subsubsubNav";
				}
				outHTML += "<tr class=\"" + theClass + "\" onMouseOver=\"doLastNav(this,1);\" onMouseOut=\"doLastNav(this,0);\"><td width=6><img src=\"../images/spacer.gif\" width=6 height=32></td><td onClick=\"parent.location='" + currentMenu[z].goLink + "';\" width=154>" + theLink + "</td></tr>";
				outHTML += "<tr><td width=160 bgcolor=\"ffffff\" colspan=2><img src=\"../images/spacer.gif\" width=1 height=1></td></tr>";
			}
			outHTML += "</table>";
		outHTML += "</div>";
	}
	document.write(outHTML);
	loaded = true;
}