// This script will highlight the navigation bar to show the current position within the website.
// It also sets a downward marker (HIGHLIGHTED_SUFFIX) in the navigation field to indicate that sub levels exist.
// The current page is highlighted and marked (HIGHLIGHTED_PREFIX) and any upper levels are highlighted.
// The structure and position of the navigation bar is defined in MENU_ITEMS below.
// 
// Version 1: Handles three levels of navigation.		20 October 2004.
//

BLANK_IMAGE = 'images/b.gif';

var code="code";var url="url";var sub="sub";

var STYLE = {
	border:2,			// item's border width, pixels; zero means "none"
	shadow:4,			// item's shadow size, pixels; zero means "none"
	color:{
		border:"#FE8407",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"d5d5d5",		// background color for the items
		bgOVER:"d5d5d5"	// background color for the item which is under mouse right now
	},
	css:{
		ON:"clsPromCMOn",		// CSS class for items
		OVER:"clsPromCMOver"	// CSS class  for item which is under mouse
	}
};

var BORDERLESS_STYLE = {
	border:0,			// item's border width, pixels; zero means "none"
	shadow:0,			// item's shadow size, pixels; zero means "none"
	color:{
		border:"teal",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"#FFFFFF",		// background color for the items
		bgOVER:"white"	// background color for the item which is under mouse right now
	},
	css:{
		ON:"clsCMOn",		// CSS class for items
		OVER:"clsCMOverColored"	// CSS class  for item which is under mouse
	}
};

var SUB_BORDERLESS_STYLE = {
	border:0,			// item's border width, pixels; zero means "none"
	shadow:0,			// item's shadow size, pixels; zero means "none"
	color:{
		border:"teal",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"#FFFFFF",		// background color for the items
		bgOVER:"white"	// background color for the item which is under mouse right now
	},
	css:{
		ON:"clsCMOn",		// CSS class for items
		OVER:"clsCMOverColored"	// CSS class  for item which is under mouse
	}
};

var MAIN_STYLE = {
	border:0,			// item's border width, pixels; zero means "none"
	shadow:0,			// item's shadow size, pixels; zero means "none"
	color:{
		border:"white",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"",		// background color for the items
		bgOVER:""	// background color for the item which is under mouse right now
	},
	css:{
		ON:"clsCMOn",
		OVER:"clsCMOverColored"
	}
};

var SUB_STYLE = {
	border:1,			// item's border width, pixels; zero means "none"
	shadow:0,			// item's shadow size, pixels; zero means "none"
	color:{
		border:"red",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"#d5d5d5",		// background color for the items
		bgOVER:"#d5d5d5"	// background color for the item which is under mouse right now
	},
	css:{
		ON:"clsCMOn",
		OVER:"clsCMOverColored"
	}
};

var SUB_SUB_STYLE = {
	border:1,			// item's border width, pixels; zero means "none"
	shadow:0,			// item's shadow size, pixels; zero means "none"
	color:{
		border:"red",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"#d5d5d5",		// background color for the items
		bgOVER:"#d5d5d5"	// background color for the item which is under mouse right now
	},
	css:{
		ON:"clsCMOn",
		OVER:"clsCMOverColored"
	}
};

var SUPER_SUB_STYLE = {
	border:1,			// item's border width, pixels; zero means "none"
	shadow:0,			// item's shadow size, pixels; zero means "none"
	color:{
		border:"white",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"#d5d5d5",		// background color for the items
		bgOVER:"#d5d5d5"	// background color for the item which is under mouse right now
	},
	css:{
		ON:"clsCMSubOn",
		OVER:"clsCMSubHighlightedOver"
	}
};

var HIGHLIGHTED = {
	border:0,
	shadow:0,
	color:{
		border:"white",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"#d5d5d5",		// background color for the items
		bgOVER:"#d5d5d5"	// background color for the item which is under mouse right now
	},
	css:{
		ON:"clsCMHighlightedOn ",
		OVER:"clsCMHighlightedOver "
	}
};

var SUB_HIGHLIGHTED = {
	border:1,
	shadow:0,
	color:{
		border:"white",
		shadow:"#DBD8D1",
		bgON:"#d5d5d5",
		bgOVER:"#d5d5d5"
	},
	css:{
		ON:"clsCMSubHighlightedOn",
		OVER:"clsCMSubHighlightedOver"
	}
};

var STYLE_V_FIRST = {
	"border":1, 
	"borders":[1,1,1,0], 
	"shadow":0, 
	"color":{
		border:"teal",
		shadow:"#DBD8D1",
		bgON:"white",
		bgOVER:"white"
	},
	 "css":{
		ON:"clsCMOn",
		OVER:"clsCMOverColored"
	}
}; 
var STYLE_V_MIDDLE = {"border":1, "borders":[1,0,1,0], "shadow":0, "color":{
		border:"teal",
		shadow:"#DBD8D1",
		bgON:"white",
		bgOVER:"white"
	},
 "css":{
		ON:"clsCMOn",
		OVER:"clsCMOverColored"
	}
}; 
var STYLE_V_LAST = {"border":1, "borders":[1,0,1,1], "shadow":0, "color":{
		border:"teal",
		shadow:"#DBD8D1",
		bgON:"white",
		bgOVER:"white"
	},
 "css":{
		ON:"clsCMOn",
		OVER:"clsCMOverColored"
	}
}; 
var STYLE_V_ALL = {"border":1, "shadow":0, "color":{
		border:"teal",
		shadow:"#DBD8D1",
		bgON:"white",
		bgOVER:"white"
	},
 "css":{
		ON:"clsCMOn",
		OVER:"clsCMOverColored"
	}
}; 


var HIGHLIGHTED_PREFIX = '';
var HIGHLIGHTED_SUFFIX = '';
var HOME_PREFIX = '<img src="images/roof.gif" align="center" /> ';

var glblHigh = 0;
var glblSub = 0;

function highlightItem(items) {								// Check all top level pages.
	for (var i = 1; i < items.length; i++)
		if (items[i]) {
			if (!items[i].format)
				items[i].format = {};

			items[i].format.style = MAIN_STYLE;

			if (items[i].url && location.href.indexOf(items[i].url) >= 0) {		
				items[i].format.style = HIGHLIGHTED;			// Highlight if current page.
				items[i].code = HIGHLIGHTED_PREFIX + items[i].code;

			}
			
			if (items[i].sub) {						// If sub pages exist.......
				items[i].code = items[i].code + " " + HIGHLIGHTED_SUFFIX;		// .........set top level that sub pages exist.
	
				items[i].sub = highlightSubItem(items[i].sub);		// Check all sub pages.
				if (glblHigh == 1) {					// If sub page is current page.......
					items[i].format.style = HIGHLIGHTED;		// ............ highlight top level.
				
				}
			}
		}	

	return items;
}

function highlightSubItem(items) {							// Check all sub pages.
	glblHigh = 0;
	for (var i = 1; i < items.length; i++)
		if (items[i]) {
			if (!items[i].format)
				items[i].format = {};

			items[i].format.style = SUB_STYLE;


			if (items[i].url && location.href.indexOf(items[i].url) >= 0) {
				items[i].format.style = SUB_HIGHLIGHTED;			// Highlight if current page.
				items[i].code = HIGHLIGHTED_PREFIX + items[i].code;
				glblHigh = 1;					// Set indicator to highlight top level.
			}

			if (items[i].sub) {						// If sub-sub pages exist.........
				items[i].code = items[i].code + " " + HIGHLIGHTED_SUFFIX;		// .......set sub level that sub-sub pages exist.
	
				items[i].sub = highlightSuperItem(items[i].sub);		// Check all sub-sub pages.
				if (glblSub == 1) {					// If sub-sub page is current page.........
					items[i].format.style = SUB_HIGHLIGHTED;		// ...........highlight sub level.
				
				}
			}

			
		}	

	return items;
}

function highlightSuperItem(items) {							// Check all sub-sub pages.
	glblSub = 0;
	for (var i = 1; i < items.length; i++)
		if (items[i]) {
			if (!items[i].format)
				items[i].format = {};

			items[i].format.style = SUB_SUB_STYLE;

			if (items[i].url && location.href.indexOf(items[i].url) >= 0) {
				items[i].format.style = HIGHLIGHTED;			// Highlight if current page.
				items[i].code = HIGHLIGHTED_PREFIX + items[i].code;	
				glblSub = 1;					// Set indicator to highlight sub level.
				glblHigh = 1;					// Set indicator to highlight top level.
			}
			
		}	

	return items;
}


var MENU_ITEMS =
[
	{"pos":"relative", "style":MAIN_STYLE, "leveloff":[0,0], "size":[22,70], "itemoff":[0,70], delay:200},
	{code:"Home", url:"index.htm", format: {"size":[22,70]}},
	{code:"About Us", url:"aboutus.htm", format: {"itemoff":[22,0], "size":[22,70]}},
	{code:"Services", url:"services.htm", format: {"itemoff":[22,0], "size":[22,70]}},
	{code:"Lead Free", url:"leadfree.htm", format: {"itemoff":[22,0], "size":[22,70]}},
	{code:"Transformers and Coils", url:"transform.htm", format: {"itemoff":[22,0], "size":[34,80]}},
	{code:"Policies", url:"policies.htm", format: {"itemoff":[34,0], "size":[22,70]}},
	{code:"Contact Us", url:"contact.htm", format: {"itemoff":[22,0], "size":[22,70]}},
	{code:"Downloads and Links", url:"links.htm", format: {"itemoff":[22,0], "size":[34,80],arrow:"images/arrright.gif", arrsize:[7,10]},
	sub:[
		{"leveloff":[6,80], "itemoff":[0,80]},
		{code:"Links", url:"links.htm", format: {"size":[22,70]}},
		{code:"Downloads", url:"links.htm", format: {image:"images/arrdwn150.jpg", imgsize:[22,130],"size":[22,340],arrow:"images/arrdown.gif", arrsize:[14,10], itemoff:[0,70]},
		sub:[
			{"itemoff":[22,0], "leveloff":[22,0], "size":[22,170]},
			{code:"Non Disclosure Agreement", url:"nda.pdf",target:"_blank", format: {image:null}},
			{code:"PCBA Technical Capabilities", url:"techcaps.pdf",target:"_blank", format: {image:null}},
			{code:"Lead Free Fact Sheet", url:"leadfree.pdf",target:"_blank", format: {image:null}},
			{code:"Plastic Mouldings", url:"plasmould.pdf",target:"_blank", format: {image:null}},
			{code:"Transformer Requirements Fact Sheet", url:"transform.PDF", target:"_blank", format: {"itemoff":[-66,170], "size":[22,170],image:null}},
			{code:"Sheet Metalwork Information", url:"sheetmetl.pdf", target:"_blank", format: {"size":[22,170],image:null}},
			{code:"Die Casting Information", url:"diecast.pdf", target:"_blank", format: {"size":[22,170],image:null}},
			{code:"", url:"links.htm", format: {"size":[22,170],image:null}}
			]
		},
		]
	}
];

MENU_ITEMS = highlightItem(MENU_ITEMS);
