// 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:"green",		// background color for the items
		bgOVER:"green"	// 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:"white",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"white",		// background color for the items
		bgOVER:"white"	// 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:"white",	// color of the item border, if any
		shadow:"#DBD8D1",	// color of the item shadow, if any
		bgON:"white",		// background color for the items
		bgOVER:"white"	// background color for the item which is under mouse right now
	},
	css:{
		ON:"clsCMOn",
		OVER:"clsCMSubHighlightedOver"
	}
};

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:"#66ff66",		// background color for the items
		bgOVER:"#99ff99"	// 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:"white",		// background color for the items
		bgOVER:"white"	// 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:"white",
		bgOVER:"white"
	},
	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":[22,0], "size":[22,70], "itemoff":[0,70], delay:200},
	{code:"Home", url:"index.htm", format: {"size":[22,50]}},
	{code:"About Me", url:"aboutme.htm", format: {"itemoff":[0,50], "size":[22,80]}},
	{code:"Galleries", url:"gallery.htm", format: {"itemoff":[0,80], "size":[22,80]},
		sub:[
			{"itemoff":[21,0], "leveloff":[0,0],"size":[22,140]},
			{code:"Introduction", url:"gallery.htm"},
			{code:"The Alhambra", url:"alhambra.htm", format: {itemoff:[22,0]}},
			{code:"The Grand Canyon", url:"canyon.htm", format: {itemoff:[22,0]}},
			{code:"The Tilda Commission", url:"tilda.htm", format: {itemoff:[22,0]}},
			{code:"Jewellery", url:"jewellery.htm", format: {itemoff:[22,0]}},
			{code:"Meditations on Angkor", url:"angkor.htm", format: {itemoff:[22,0]}},
			{code:"Postcards from Alaska", url:"alaska.htm", format: {itemoff:[22,0]}},
			{code:"Out of China", url:"china.htm", format: {itemoff:[22,0]}},
			{code:"New York, New York", url:"newyork.htm", format: {itemoff:[22,0]}},
			{code:"Architraves & Angels", url:"angels.htm", format: {itemoff:[22,0]}}
		]
	},
	{code:"Exhibitions", url:"exhibitns.htm", format: {"itemoff":[0,80], "size":[22,90]}},
	{code:"Contact Me", url:"contact.htm", format: {"itemoff":[0,90], "size":[22,100]}},
	{code:"Help", url:"help.htm", format: {"itemoff":[0,100], "size":[22,50]}}	

];

MENU_ITEMS = highlightItem(MENU_ITEMS);
