/*
Name:		Dynamic HTML menu system
Author:		Stephen Brown, SDB, stephen.brown@akqa.com
Company:	AKQA
Client:		Nikon
Description:	Dynamic HTML menu system for collapsable left hand navigation.
			must have background image, be a minimum length, be able
			to stretch and contain 2 levels of navigation.
Version:	1.00
*/

// Analyst
// Constants
var doc_url = document.location.toString();
var nikon_site =  (doc_url.indexOf('.analyst.') != -1) ? 'ANALYST' : ((doc_url.indexOf('.akqa.') != -1) || (doc_url.indexOf('uk.localnet') != -1)) ? 'DEV' : 'LIVE';
var isAnalystTesting = (nikon_site == 'ANALYST') ? true : false;
var isLiveServer = (nikon_site == 'LIVE' && !isAnalystTesting) ? true : false;
var strRedirect = location.protocol+"//go.nikon.co.uk/redirect.dll?";
var strAd = location.protocol+"//go.nikon.co.uk/ad.dll?";

document.write('<SCRIPT LANGUAGE="Javascript" SRC="http://go.nikon.co.uk/javascript/aainsertion.2.00.js"></SCRIPT>');

// Click
function logClick(add, url) {
// alert(add);
	nkn_getTrack(add, 'Click');
	if(url) {
		if (url.indexOf("javascript:") != -1) {
			eval(url);
		} else {
			document.location.href=url;
		}
	}
}
// Nikon Tracker
function NikonTracker(pageName) {
	AAGetTracker(NikonTracking[pageName]);
}
// Impression
function AAGetTracker(add) {
	nkn_getTrack(add, 'Impression');
}
// Multiple Impressions
function AACampaignTracks() {
	for(var i=0;i<AACampaignTracks.arguments.length;AAGetTracker(AACampaignTracks.arguments[i]),i++);
}
// run the tracking for Click / Impression(s)
var getAdImage;
function nkn_getTrack(add, adType) {
	if(isLiveServer) {
		var getAdQryStr = '';
		getAdImage = new Image(1,1);
		if(adType == 'Impression') getAdQryStr += '&RandomID=' + AACreateAUID();
		getAdImage.src = ((adType == 'Impression') ? strAd : strRedirect) + add + getAdQryStr;
	} else {
		if(isAnalystTesting) alert("DEV SERVER\n==========\n\n" + adType + ": " + add);
	}
}
// Analyst tracking End

/* Browser detection */
var isLAYERS = (document.layers) ? true : false;
var isALL = (document.all) ? true : false;
var isDOM = (document.getElementById) ? true : false;
var isWin = (navigator.platform.indexOf("Win") != -1) ? true : false;
var isMac = (navigator.platform.indexOf("Mac") != -1) ? true : false;
var IE5 = (navigator.userAgent.indexOf("MSIE 5.") != -1) ? true : false;
var IE55 = (navigator.userAgent.indexOf("MSIE 5.5") != -1) ? true : false;
var IE45 = (navigator.userAgent.indexOf("MSIE 4.5") != -1) ? true : false;
var Netscape6 = (navigator.userAgent.indexOf("Netscape6") != -1) ? true : false;
IE5 = (IE5 && !IE55) ? true : false;

// Test for Mac Os X
var OsXTest = false;
for (var ixo = 0; ixo < navigator.plugins.length; ixo++) { if (navigator.plugins[ixo].name.indexOf("Carbon") != -1) OsXTest = true; }
var isOSX = (OsXTest && isMac) ? true : false;

var useDIV = (isALL || isDOM) ? true : false;
var useLAYER = (isLAYERS) ? true : false;
var useSTATIC = (useLAYER || (isDOM && !isALL) || (isMac && !IE5)) ? true : false;
// useSTATIC is set to true if browser is Netscape 4 or Netscape 6 or IE4.5 on the Mac

var HIDE = (isLAYERS) ? 'hide' : 'hidden';
var SHOW = (isLAYERS) ? 'show' : 'visible';

function nkn_dmenu() {
	var navigation = '';
	var navigation2 = '';
	var whiteSpace = '';
	var backgroundImage = '';
	var backgroundBody = '';
	var backgroundColor = '';
	var backgroundWidth = '';
	var dividerColor = '';
	var navArray = new Array;
	var imagePath = 'images/'; // DEFAULT - DO NOT CHANGE
	var currentNav = -1;
	var styles = new Array;
	var finalOutput = '';
	var DEFAULT_TOP = '20';
	var DEFAULT_LEFT = '9';
	var DEFAULT_SPACER = '17';
	var DEFAULT_SPACER_SUB = '13';
	var DEFAULT_GAP = '4';
	var DEFAULT_STYLE = new Array;
	var Adverts = new Array; // For use with left navigation advertisements
	var ROWSPAN = 5;

	this.navigation = navigation;
	this.navigation2 = navigation2;
	this.whiteSpace = whiteSpace;
	this.backgroundImage = backgroundImage;
	this.backgroundBody = backgroundBody;
	this.backgroundColor = backgroundColor;
	this.backgroundWidth = backgroundWidth;
	this.dividerColor = dividerColor;
	this.navArray = navArray;
	this.imagePath = imagePath;
	this.currentNav = currentNav;
	this.styles = styles;
	this.finalOutput = finalOutput;
	this.DEFAULT_TOP = DEFAULT_TOP;
	this.DEFAULT_LEFT = DEFAULT_LEFT;
	this.DEFAULT_SPACER = DEFAULT_SPACER;
	this.DEFAULT_SPACER_SUB = DEFAULT_SPACER_SUB;
	this.DEFAULT_GAP = DEFAULT_GAP;
	this.DEFAULT_STYLE = DEFAULT_STYLE;
	this.Adverts = Adverts;
	this.ROWSPAN = 5;

	/* public methods to set above variables */
	this.addMenu = function(name, URL, newWindow, GUID) {
		arrLength = this.navArray.length;
		this.navArray[this.arrLength] = new Array();
		this.navArray[this.arrLength].Name = name.replace(/&/,'&amp;');
		this.navArray[this.arrLength].URL = URL;
		this.navArray[this.arrLength].newWindow = newWindow;
		this.navArray[this.arrLength].GUID = GUID;
	}
	this.addSubMenu = function(parentID, name, URL, newWindow, GUID) {
		arrLength = this.navArray[parentID].length;
		this.navArray[parentID][arrLength] = new Array(name, URL, newWindow, GUID);
	}
	/* end public methods */

	/* private methods */
	function setMenu(MenuStyle) {
		parseArr = this.getStyle(MenuStyle);
		this.setBackground(parseArr[0],parseArr[1],parseArr[2],parseArr[3]);
		this.currentNav = MenuStyle;
	}
	function addStyle(name, backgroundColor, dividerColor, backgroundWidth, linkHoverColor, location) {
		location = (location != null) ? location : this.styles.length;
		this.styles[location] = new Array(name, backgroundColor, dividerColor, backgroundWidth, linkHoverColor);
	}
	function endOutput(doItAnyway, removeBackground) {
		if((!doItAnyway && !IE5) || (doItAnyway && IE5) || (Netscape6 && isMac && !doItAnyway)) {
			document.write(this.finalOutput);
		} else if(IE5) {
			if (useSTATIC) {
				if(isMac) {
					document.write(this.finalOutput);
				}
			} else if (removeBackground) {
				document.write('<IMG SRC="'+this.imagePath+'clear.gif" WIDTH="190" HEIGHT="395" BORDER="0">');
			} else {
				document.write('<IMG SRC="'+this.backgroundBody+'" WIDTH="'+this.backgroundWidth+'" HEIGHT="395" BORDER="0">');
			}
		}
	}
	function outputImage(removeBackground) {
		if(!IE5) {
			if (useSTATIC) {
			} else if (removeBackground) {
				this.finalOutput+= '<IMG SRC="'+this.imagePath+'clear.gif" WIDTH="190" HEIGHT="395" BORDER="0">';
			} else {
				this.finalOutput+= '<IMG SRC="'+this.backgroundBody+'" WIDTH="'+this.backgroundWidth+'" HEIGHT="395" BORDER="0">';
			}
		}
	}
	function writeStylesheet() {
		var fontSizes = (isLAYERS) ? new Array('9pt','8pt') : new Array('8pt','8pt');
		var countSize = (isLAYERS) ? '8pt' : '7pt';
		outputStyle = '<STYLE TYPE="text/css">\n';
		outputStyle+= '<!--\n';
		outputStyle+= '.Menu {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= ' font-size: '+fontSizes[0]+';\n';
		outputStyle+= ' font-weight:bold;\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= ' color: #FFFFFF;\n';
		outputStyle+= '}\n';
		outputStyle+= '.Menu:hover {\n';
		outputStyle+= ' color: #'+this.styles[this.currentNav][2]+';\n';
		outputStyle+= '}\n';
		outputStyle+= '.Count {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= ' font-size: ' + countSize + ';\n';
		outputStyle+= ' font-weight:bold;\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= ' color: #FFFFFF;\n';
		outputStyle+= '}\n';
		outputStyle+= '.Count:hover {\n';
		outputStyle+= ' color: #'+this.styles[this.currentNav][2]+';\n';
		outputStyle+= '}\n';
		outputStyle+= '.MenuSelected {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= ' font-size: '+fontSizes[0]+';\n';
		outputStyle+= ' font-weight:bold;\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= ' color: #'+this.styles[this.currentNav][2]+';\n';
		outputStyle+= '}\n';
		outputStyle+= '.SubMenu {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= ' font-size: '+fontSizes[1]+';\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= ' color: #FFFFFF;\n';
		outputStyle+= '}\n';
		outputStyle+= '.SubMenu:hover {\n';
		outputStyle+= ' color: #'+this.styles[this.currentNav][2]+';\n';
		outputStyle+= '}\n';
		outputStyle+= '.SubMenuSelected {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= ' font-size: '+fontSizes[1]+';\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= ' color: #'+this.styles[this.currentNav][2]+';\n';
		outputStyle+= '}\n';
		outputStyle+= '.norepeat {\n';
		outputStyle+= ' background-repeat: no-repeat;\n';
		outputStyle+= '}\n';
		outputStyle+= '.fontSmall {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= ' font-size:70%;\n';
		outputStyle+= '}\n';
		outputStyle+= '.fontSmallWhite {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= ' font-size:70%;\n';
		outputStyle+= ' color: #FFFFFF;\n';
		outputStyle+= '}\n';
		outputStyle+= '.fontVerySmallWhite {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= ' font-size: ' + countSize + ';\n';
		outputStyle+= ' color: #FFFFFF;\n';
		outputStyle+= '}\n';
		outputStyle+= 'td {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= '}\n';
		outputStyle+= '.fontLarge {\n';
		outputStyle+= ' font-family: Tahoma, Arial;\n';
		outputStyle+= ' font-size:80%;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.bodyLink{\n';
		outputStyle+= ' color:#'+this.styles[this.currentNav][1]+';\n';
		outputStyle+= ' font-weight:bold;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.bodyLink:hover{\n';
		outputStyle+= ' color:#'+this.styles[this.currentNav][4]+';\n';
		outputStyle+= ' font-weight:bold;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.thumbLink{\n';
		outputStyle+= ' color:#ffffff;\n';
		outputStyle+= ' font-weight:bold;\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.tableLink{\n';
		outputStyle+= ' color:#'+this.styles[this.currentNav][1]+';\n';
		outputStyle+= ' text-decoration: underline;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.tableLink:hover{\n';
		outputStyle+= ' color:#'+this.styles[this.currentNav][4]+';\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.tableLink2{\n';
		outputStyle+= ' color:#FFFFFF;\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.tableLink2:hover{\n';
		outputStyle+= ' color:#'+this.styles[this.currentNav][4]+';\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.columnLink{\n';
		outputStyle+= ' color:#666666;\n';
		outputStyle+= ' font-size:85%;\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.columnLink:hover{\n';
		outputStyle+= ' color:#CCCCCC;\n';
		outputStyle+= ' font-size:85%;\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= '}\n';
		outputStyle+= 'a.navLink{\n';
		outputStyle+= ' color:#FFFFFF;\n';
		outputStyle+= ' font-size:85%;\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= '}\n';
		outputStyle+= '.columnText{\n';
		outputStyle+= ' color:#CCCCCC;\n';
		outputStyle+= ' font-size:85%;\n';
		outputStyle+= ' text-decoration: none;\n';
		outputStyle+= '}\n';
		outputStyle+= '//-->\n';
		outputStyle+= '</STYLE>\n';
		document.write(outputStyle);
	}
	function getStyle(styleNum) {
		return new Array(this.styles[styleNum][0], this.styles[styleNum][1], this.styles[styleNum][2], this.styles[styleNum][3]);
	}
	function returnValidName(strName) {
		strName = strName.replace(/[ !-?,':]*/g,'');
		return strName;
	}
	function createMap() {
		outMap = '';
		outMap+= '<MAP NAME="MinimiseMap">\n';
		outMap+= '<AREA COORDS="56,0,68,15" HREF="javascript:NikonMenu.Minimise();">\n';
		outMap+= '</MAP>\n';
		outMap+= '<MAP NAME="NavigationMap">\n';
		outMap+= '<AREA COORDS="56,0,68,15" HREF="javascript:NikonMenu.Navigation();">\n';
		outMap+= '</MAP>\n';
		this.finalOutput+= outMap;
	}
	function setBackground(imageURL, backgroundColor, dividerColor, backgroundWidth) {
		if(imageURL) {
			this.backgroundImage = this.imagePath+imageURL+'_fade.jpg';
			this.backgroundBody = this.imagePath+imageURL+'.jpg';
		} else {
			this.backgroundImage = this.imagePath+'clear.gif';
		}
		this.backgroundColor = backgroundColor;
		this.backgroundWidth = backgroundWidth;
		this.dividerColor = dividerColor.replace(/#/g,'').toLowerCase();
		return (this.backgroundImage+"\n"+this.backgroundColor+"\n"+this.backgroundWidth+"\n"+this.dividerColor);
	}

	function getContent() {


		// Start Scroll Content DIVs/LAYERs
		// For use with Items more than 5, should be catered for STATIC, NS6, IE5.0 - IE6.0 and Mac
		var outerTable = '<TR>\n' +
			'	<TD VALIGN="top" COLSPAN="2"></TD>\n' +
			'	<TD VALIGN="top" COLSPAN="2">\n' +
			'	#CONTENT#' +
			'	</TD>\n' +
			'</TR>\n';
		var innerTable = '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n' +
			'<TR>\n' +
			'	<TD VALIGN="top">\n' +
			'	<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n' +
			'	#CONTENT#' +
			'	</TABLE>\n' +
			'	</TD>\n' +
			'</TR>\n' +
			'</TABLE>\n';
		var IEContent = '<DIV ID="scrollContainer#COUNT#" STYLE="position:relative; width:140; height:'+this.scrollBarArea+'; display:none;">' +
			'<DIV ID="scrollClip#COUNT#" STYLE="position:absolute; width:140; height:'+this.scrollBarArea+'; top:0; left:0; clip:rect(2,140,'+(this.scrollBarArea + 2)+',0); visibility:inherit;">' +
			'<DIV ID="scrollLayer#COUNT#" STYLE="position:absolute; width:140; height:auto; top:0; left:0; visibility:inherit;">' +
			innerTable +
			'</DIV>' +
			'</DIV>' +
			'<DIV ID="scrollBarContainer#COUNT#" STYLE="position:absolute; width:9; height:'+this.scrollBarArea+'; top:2; left:140; visibility:inherit; filter:alpha(opacity=70);">' +
			'<IMG SRC="'+this.imagePath+'arrow_up.gif" WIDTH="9" HEIGHT="10" BORDER="0" OnMouseOver="NikonMenu.scrollNav(1);" OnMouseOut="NikonMenu.endScroll();"><BR>\n' +
			'<IMG SRC="'+this.imagePath+'clear.gif" WIDTH="9" HEIGHT="'+(this.scrollBarArea-20)+'" BORDER="0"><BR>\n' +
			'<IMG SRC="'+this.imagePath+'arrow_down.gif" WIDTH="9" HEIGHT="10" BORDER="0" OnMouseOver="NikonMenu.scrollNav(-1);" OnMouseOut="NikonMenu.endScroll();">' +
			'<DIV ID="barLayer#COUNT#" STYLE="position:absolute; width:9; height:'+this.scrollBarHeight+'; top:11; left:0;">' +
			'<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="9" HEIGHT="'+this.scrollBarHeight+'">\n' +
			'<TR><TD COLSPAN="3" BGCOLOR="#FFFFFF"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD></TR>\n' +
			'<TR>\n' +
			'	<TD BGCOLOR="#FFFFFF"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="'+(this.scrollBarHeight-2)+'" BORDER="0"></TD>\n' +
			'	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="7" HEIGHT="'+(this.scrollBarHeight)+'" BORDER="0"></TD>\n' +
			'	<TD BGCOLOR="#FFFFFF"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="'+(this.scrollBarHeight-2)+'" BORDER="0"></TD>\n' +
			'</TR>\n' +
			'<TR><TD COLSPAN="3" BGCOLOR="#FFFFFF"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD></TR>\n' +
			'</TABLE>\n' +
			'</DIV>' +
			'</DIV><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="2" HEIGHT="'+this.scrollBarArea+'" BORDER="0">' +
			'</DIV>';
		IEContent = outerTable.replace(/#CONTENT#/,IEContent);

		var ContentOut = '';
		var MenusNum = -1;

		for(Menus in this.navArray) {
			MenusNum = (Menus == this.currentNav) ? Menus : MenusNum;
			var ItemOut = '';
			var ItemsOut = '';
			var outToBlank = '';
			if(this.navArray[Menus].newWindow) {
				outToBlank = ' TARGET="_blank"';
			}

			var fontClass = '';
			this.ROWSPAN++;
			ContentOut+= '<TR>';
			if(Menus == this.currentNav) {
				fontClass = 'Selected';
				ContentOut+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
				ContentOut+= '	<TD HEIGHT="'+this.DEFAULT_SPACER+'" VALIGN="middle"><IMG SRC="'+this.imagePath+'arrow_select.gif" WIDTH="8" HEIGHT="8" BORDER="0"></TD>\n';
			} else {
				ContentOut+= '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
			}
			ContentOut+= '	<TD COLSPAN="2" VALIGN="top">';
			ContentOut+= '	<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n';
			ContentOut+= '	<TR>\n';
			ContentOut+= '		<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="7" HEIGHT="2" BORDER="0"></TD>\n';
			ContentOut+= '		<TD HEIGHT="'+this.DEFAULT_SPACER+'" VALIGN="middle">';
			if(this.navArray[Menus].URL.indexOf("javascript") != -1) {
				var newURL = this.navArray[Menus].URL+'" OnMouseDown="logClick(\''+this.navArray[Menus].GUID+'\');';
			} else {
				var newURL = 'javascript:logClick(\''+this.navArray[Menus].GUID+'\',\''+this.navArray[Menus].URL+'\');';
			}
			ContentOut+= '<A HREF="'+newURL+'" CLASS="Menu'+fontClass+'"'+outToBlank+'>'+this.navArray[Menus].Name+'</A>';
			ContentOut+= '</TD>\n';
			ContentOut+= '	</TR>\n';
			ContentOut+= '	</TABLE>\n';
			ContentOut+= '	</TD>\n';
			ContentOut+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
			ContentOut+= '</TR>\n';

			useColor = (Menus == this.navArray.length-1 && (this.navArray[Menus].length < 1 || this.currentNav != Menus)) ? 'ffffff' : this.dividerColor;
			if(Menus == this.navArray.length-1 && (this.navArray[Menus].length < 1 || this.currentNav != Menus)) {
			} else {
				ContentOut+= '<TR>\n';
				ContentOut+= '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
				ContentOut+= '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'1px_'+useColor+'.gif" WIDTH="162" HEIGHT="1" BORDER="0"></TD>\n';
				ContentOut+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
				ContentOut+= '</TR>\n';

				this.ROWSPAN++;
			}

			if(Menus == this.currentNav && this.navArray[Menus].length != 0) {
				ItemOut+= '<TR><TD COLSPAN="5" HEIGHT="'+this.DEFAULT_GAP+'"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD></TR>\n';
				this.ROWSPAN++;
				for(Subs in this.navArray[Menus]) {
					if( (Subs == parseInt(Subs)) && typeof this.navArray[Menus][Subs][0] != "undefined") {
						outToBlank = '';
						if(this.navArray[Menus][Subs][2]) {
							outToBlank = ' TARGET="_blank"';
						}
						fontClass = document.URL.substring(7);
						fontClass = fontClass.substring(fontClass.indexOf("/"));
						fontClass = (fontClass == this.navArray[Menus][Subs][1]) ? 'Selected' : '';
						ItemOut+= '<TR>\n';
						this.ROWSPAN++;
						ItemOut+= '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
						ItemOut+= '	<TD COLSPAN="2">';
						ItemOut+= '	<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n';
						ItemOut+= '	<TR>\n';
						ItemOut+= '		<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="14" HEIGHT="2" BORDER="0"></TD>\n';
						ItemOut+= '		<TD HEIGHT="'+this.DEFAULT_SPACER_SUB+'" VALIGN="middle">';
						if(this.navArray[Menus].URL.indexOf("javascript") != -1 || outToBlank) {
							var newURL = this.navArray[Menus][Subs][1]+'" OnMouseDown="logClick(\''+this.navArray[Menus][Subs][3]+'\');';
						} else {
							var newURL = 'javascript:logClick(\''+this.navArray[Menus][Subs][3]+'\',\''+this.navArray[Menus][Subs][1]+'\');';
						}
						ItemOut+= '<A HREF="'+newURL+'" CLASS="SubMenu'+fontClass+'"'+outToBlank+'>'+this.navArray[Menus][Subs][0]+'</A>';
						ItemOut+= '</TD>\n';
						ItemOut+= '	</TR>\n';
						ItemOut+= '	</TABLE>\n';
						ItemOut+= '	</TD>\n';
						ItemOut+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
						ItemOut+= '</TR>\n';
						if(this.scrollingEnabled && this.navArray[Menus][5]) {
							this.ROWSPAN--;
						}
					}
				}
				ItemOut+= '<TR><TD COLSPAN="5" HEIGHT="'+this.DEFAULT_GAP+'"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD></TR>\n';
				this.ROWSPAN++;
				useColor = (Menus == this.navArray.length-1 && Subs == this.navArray[Menus].length-1) ? 'ffffff' : this.dividerColor;
				if(Menus == this.navArray.length-1 && Subs == this.navArray[Menus].length-1) {
				} else {
					if(!useSTATIC && !this.scrollingEnabled && this.navArray[Menus].length > 5 && Menus == this.currentNav) {
						this.ROWSPAN++;
						ItemOut+= '<TR>\n';
						ItemOut+= '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
						ItemOut+= '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'1px_'+this.useColor+'.gif" WIDTH="162" HEIGHT="1" BORDER="0"></TD>\n';
						ItemOut+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
						ItemOut+= '</TR>\n';
					}
				}
				if(!useSTATIC && ((this.scrollingEnabled && this.navArray[Menus].length > this.scrollItemsInList && Menus == this.currentNav) || !this.scrollingEnabled)) {
					ItemsOut+= ItemOut;
					ContentOut+= '#CONTENT#';
					ContentOut = ContentOut.replace(/#CONTENT##CONTENT#/,'#CONTENT#');
				} else {
					ContentOut+= ItemOut;
				}
			}
			/********************************************************/
			/* This is where I Add to a scrolling layer if required */
			/********************************************************/
			if(!useSTATIC && ((this.scrollingEnabled && this.navArray[Menus].length > this.scrollItemsInList && Menus == this.currentNav) || !this.scrollingEnabled)) {
				var newContent = IEContent.replace(/#COUNT#/g,Menus).replace(/#CONTENT#/g,ItemsOut);
				ContentOut = ContentOut.replace(/#CONTENT#/g, newContent);

				this.ROWSPAN+=2;
				ContentOut+= '<TR><TD COLSPAN="5" HEIGHT="'+this.DEFAULT_GAP+'"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD></TR>\n';
				ContentOut+= '<TR>\n';
				ContentOut+= '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
				ContentOut+= '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'1px_'+this.useColor+'.gif" WIDTH="162" HEIGHT="1" BORDER="0"></TD>\n';
				ContentOut+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
				ContentOut+= '</TR>\n';
			}
		}
		return ContentOut;
	}
	function PlaceNavigation() {
		var xCoord;
		if (useSTATIC) {
			// do Nothing
		} else if (useDIV && isALL) {

			xCoord = document.all['trackPosition'].offsetWidth;
			xCoord-= 755;
			xCoord/= 2;
			xCoord+= 9;
			if(xCoord < parseInt(this.DEFAULT_LEFT)) {
				xCoord = parseInt(this.DEFAULT_LEFT);
			}

			//var newHeight = (isMac) ? 'auto' : parseInt(document.body.scrollHeight) - 30;

			var newHeight = '';

			if (isMac && !isOSX) newHeight = 'auto';
			else if (isMac && isOSX) newHeight = parseInt(document.body.scrollHeight) - 111;
			else newHeight = parseInt(document.body.scrollHeight) - 30;


			this.navigation.setLeft(xCoord);
			this.navigation.setHeight(newHeight);
			this.navigation2.setLeft(xCoord);

			this.whiteSpace.setHeight(this.navigation.getHeight());
			this.whiteSpace.setLeft(xCoord - 9);
			this.whiteSpace.setVisible();

			if(this.currentNav != -1 && isALL && typeof document.all['scrollContainer'+this.currentNav] != "undefined") {
				document.all['scrollContainer'+this.currentNav].style.display = 'block';
			}
			setTimeout("javascript:NikonMenu.navigation.showMenu();",1);
		}
	}
	function init() {
		if(IE5) {
			if(document.cookie && document.cookie.indexOf("HistoryCount") != -1) {
				window.history.HistoryCount = parseInt(document.cookie.substring(document.cookie.indexOf("HistoryCount=")+13,document.cookie.indexOf("HistoryCount=")+16));
			}
		}
		if(!window.history.HistoryCount) {
			window.history.HistoryCount = 0;
		}
		this.addToHistory();
		NikonMenu.PlaceNavigation();
	}
	function addToHistory(goForth) {
		window.history.HistoryCount++;
		if(IE5) {
			var cookiedomain = (location.toString().indexOf(".akqa") != -1) ? "akqa.co.uk" : "nikon.co.uk";
			var currentDate = new Date();
			var expireYear = currentDate.getYear();
			expireYear++;
			document.cookie = "HistoryCount="+parseInt(window.history.HistoryCount)+"; domain="+cookiedomain+"; path=/;";
		}
	}
	function createCounter(digits) {
			var Counter = '';
			if(useSTATIC || isMac) {
				Counter+= '<TR>\n';
				Counter+= '	<TD COLSPAN="2"><IMG SRC="/images/clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
				Counter+= '	<TD COLSPAN="2" VALIGN="bottom" ALIGN="center">\n';
				Counter+= '	<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="132">\n';
				Counter+= '	<TR>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="'+this.imagePath+'dotted_vertical.gif" WIDTH="1" HEIGHT="31" BORDER="0"></TD>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="6" HEIGHT="2" BORDER="0"></TD>\n';
				Counter+= '		<TD ALIGN="left" VALIGN="top" NOWRAP CLASS="fontVerySmallWhite"><A HREF="/nikon_world/terms_of_use/" ONCLICK="javascript:logClick(\'5068B4622EC211D7B61B00902798ABE9\');" CLASS="Count">Terms of use</A><BR><A HREF="/nikon_world/privacy_policy/" ONCLICK="javascript:logClick(\'5068B4822EC211D7B61B00902798ABE9\');" CLASS="Count">Privacy policy</A><BR>&copy; 2003 Nikon UK Ltd</TD>\n';
				Counter+= '	</TR>\n';
				Counter+= '	<TR><TD COLSPAN="3" HEIGHT="8"><IMG SRC="/images/clear.gif" WIDTH="2" HEIGHT="8" BORDER="0"></TD></TR>\n';
				Counter+= '	</TABLE>\n';
				Counter+= '	</TD>\n';
				Counter+= '	<TD><IMG SRC="/images/clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
				Counter+= '</TR>\n';
			} else {
				Counter+= '<TR>\n';
				Counter+= '	<TD COLSPAN="2"></TD>\n';
				Counter+= '	<TD COLSPAN="2" VALIGN="bottom" HEIGHT="100%" ALIGN="center">\n';
				Counter+= '	<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="132">\n';
				Counter+= '	<TR>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"><BR><IMG SRC="'+this.imagePath+'dotted_vertical.gif" WIDTH="1" HEIGHT="31" BORDER="0"></TD>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="6" HEIGHT="2" BORDER="0"></TD>\n';
				Counter+= '		<TD ALIGN="left" VALIGN="top" NOWRAP CLASS="fontVerySmallWhite"><A HREF="/nikon_world/terms_of_use/" ONCLICK="javascript:logClick(\'5068B4622EC211D7B61B00902798ABE9\');" CLASS="Count">Terms of use</A><BR><A HREF="/nikon_world/privacy_policy/" ONCLICK="javascript:logClick(\'5068B4822EC211D7B61B00902798ABE9\');" CLASS="Count">Privacy policy</A><BR>&copy; 2003 Nikon UK Ltd</TD>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="7" HEIGHT="2" BORDER="0"></TD>\n';
				Counter+= '		<TD VALIGN="top" ALIGN="left"><IMG SRC="'+this.imagePath+'bracket_left.gif" WIDTH="5" HEIGHT="31" BORDER="0"></TD>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="3" HEIGHT="2" BORDER="0"></TD>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="/images/clear.gif" WIDTH="1" HEIGHT="2" BORDER="0"><BR><IMG SRC="'+this.imagePath+'digit_'+digits[0]+'.gif" WIDTH="15" HEIGHT="27" BORDER="0" ALT="'+digits[0]+'"></TD>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="2" HEIGHT="2" BORDER="0"></TD>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="/images/clear.gif" WIDTH="1" HEIGHT="2" BORDER="0"><BR><IMG SRC="'+this.imagePath+'digit_'+digits[1]+'.gif" WIDTH="15" HEIGHT="27" BORDER="0" ALT="'+digits[1]+'"></TD>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="3" HEIGHT="2" BORDER="0"></TD>\n';
				Counter+= '		<TD VALIGN="top"><IMG SRC="'+this.imagePath+'bracket_right.gif" WIDTH="5" HEIGHT="31" BORDER="0"></TD>\n';
				Counter+= '	</TR>\n';
				Counter+= '	<TR><TD COLSPAN="11" HEIGHT="8"></TD></TR>\n';
				Counter+= '	</TABLE>\n';
				Counter+= '	</TD>\n';
				Counter+= '	<TD></TD>\n';
				Counter+= '</TR>\n';
			}
			return Counter;
	}
	this.setMenu = setMenu;
	this.addStyle = addStyle;
	this.endOutput = endOutput;
	this.outputImage = outputImage;
	this.writeStylesheet = writeStylesheet;
	this.getStyle = getStyle;
	this.returnValidName = returnValidName;
	this.createMap = createMap;
	this.setBackground = setBackground;
	this.getContent = getContent;
	this.PlaceNavigation = PlaceNavigation;
	this.init = init;
	this.addToHistory = addToHistory;
	this.createCounter = createCounter;
	/* end private */

	this.Minimise = function() {
		this.navigation.hideMenu();
		this.navigation2.showMenu();
	}
	this.Navigation = function() {
		this.navigation2.hideMenu();
		this.navigation.showMenu();
	}

	this.createNavigation = function(removeBackground) {
		this.outputImage(removeBackground);

		var navigationOutput = '';

		if (useSTATIC) {
			navigationOutput+= '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" HEIGHT="100%" BGCOLOR="#'+this.backgroundColor+'">\n';
			navigationOutput+= '<TR>\n';
			navigationOutput+= '<TD VALIGN="top">\n';
			navigationOutput+= '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" HEIGHT="404">\n';
		} else {
			navigationOutput+= '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" HEIGHT="100%" WIDTH="190" BACKGROUND="'+this.backgroundImage+'" CLASS="norepeat">\n';
			if (IE5) {
				navigationOutput+= '<TR>\n';
				navigationOutput+= '<TD VALIGN="top" HEIGHT="404">\n';
				navigationOutput+= '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n';
			}
		}

		navigationOutput+= '<TR>\n';
		if (useSTATIC) {
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="10" HEIGHT="10" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="8" HEIGHT="10" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="64" HEIGHT="10" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="98" HEIGHT="10" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="10" HEIGHT="10" BORDER="0"></TD>\n';
			if(!removeBackground && parseInt(this.backgroundWidth)-190 > 0) {
				navigationOutput+= ' <TD VALIGN="top" ROWSPAN="#ROWSPAN#" BGCOLOR="#FFFFFF"><IMG SRC="'+this.backgroundBody.replace(/.jpg/,"_ns.jpg")+'" WIDTH="'+(parseInt(this.backgroundWidth)-190)+'" HEIGHT="395" BORDER="0"></TD>\n';
			}
		} else {
			navigationOutput+= '	<TD ROWSPAN="#ROWSPAN#" BGCOLOR="#FFFFFF"><IMG SRC="'+this.imagePath+'1px_ffffff.gif" WIDTH="1" HEIGHT="10" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="10" HEIGHT="10" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="8" HEIGHT="10" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="64" HEIGHT="10" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="98" HEIGHT="10" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="10" HEIGHT="10" BORDER="0"></TD>\n';
		}
		navigationOutput+= '</TR>\n';
		this.ROWSPAN++;

		navigationOutput+= '<TR>\n';
		navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
		navigationOutput+= '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'nikon_logo.gif" WIDTH="72" HEIGHT="71" BORDER="0" ALT="Nikon"></TD>\n';
		if (useSTATIC) {
			navigationOutput += '	<TD COLSPAN="2"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
		} else {
			if(removeBackground) {
				navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
			} else {
				if(this.currentNav==0){ //Added by matthew.elwin@akqa.com because need a different image for each randon homepage image
					navigationOutput+= '	<TD VALIGN="bottom" ALIGN="right"><IMG SRC="'+this.imagePath+'btn_minimise_'+this.currentNav+'_'+iPageScheme+'.gif" WIDTH="68" HEIGHT="15" BORDER="0" ALT="MINIMISE" USEMAP="#MinimiseMap"></TD>\n';
				} else {
					navigationOutput+= '	<TD VALIGN="bottom" ALIGN="right"><IMG SRC="'+this.imagePath+'btn_minimise_'+this.currentNav+'.gif" WIDTH="68" HEIGHT="15" BORDER="0" ALT="MINIMISE" USEMAP="#MinimiseMap"></TD>\n';
				}
			}
			navigationOutput+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="11" HEIGHT="1" BORDER="0"></TD>\n';
		}
		navigationOutput+= '</TR>\n';

		navigationOutput+= '<TR><TD COLSPAN="5" HEIGHT="3"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="2" HEIGHT="15" BORDER="0"></TD></TR>\n';

		if(useSTATIC) {
			navigationOutput+= '<TR>\n';
			navigationOutput+= '	<TD><IMG SRC="/images/clear.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
			navigationOutput+= '	<TD COLSPAN="4" VALIGN="top" HEIGHT="265">\n';
			navigationOutput+= '	<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n';
		}

		navigationOutput+= this.getContent();
		if(useSTATIC) {
			navigationOutput+= '	</TABLE>\n';
			navigationOutput+= '	</TD>\n';
			navigationOutput+= '</TR>\n';
		}

		navigationOutput+= '<TR><TD COLSPAN="5" HEIGHT="8"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="2" HEIGHT="8" BORDER="0"></TD></TR>\n';

		if (useSTATIC) {
			navigationOutput+= '	<TR><TD COLSPAN="5"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="2" HEIGHT="20" BORDER="0"></TD></TR>\n';
			navigationOutput+= this.createCounter();
			navigationOutput+= '	</TABLE>\n';
			navigationOutput+= '	</TD>\n';
			navigationOutput+= '</TR>\n';
		} else if (useDIV && isALL) {
			// Inserting Time Based Battery Image
			// Back (History)
			var batteryImage = 'battery';
			var newDate = new Date();
			if(!window.history.logonTime) {
				tempStr = parseInt(newDate.getSeconds());
				tempStr+= parseInt(newDate.getMinutes() * 60);
				tempStr+= parseInt(newDate.getHours() * 60 * 60);
				window.history.logonTime = tempStr;
			}
			tempStr = parseInt(newDate.getSeconds());
			tempStr+= parseInt(newDate.getMinutes() * 60);
			tempStr+= parseInt(newDate.getHours() * 60 * 60);
			var newDateStr = tempStr;

			/* If battery runs out, get a new one
			if(parseInt(newDateStr - window.history.logonTime) > 60*60*1.25) {
				batteryImage = 'battery_full';
				window.history.logonTime = tempStr;
				alert("new battery has been inserted");
			} else*/
			if(parseInt(newDateStr - window.history.logonTime) > 60*60) {
				batteryImage = 'battery_empty';
			} else if(parseInt(newDateStr - window.history.logonTime) > 60*45) {
				batteryImage = 'battery_1_4';
			} else if(parseInt(newDateStr - window.history.logonTime) > 60*30) {
				batteryImage = 'battery_2_4';
			} else if(parseInt(newDateStr - window.history.logonTime) > 60*15) {
				batteryImage = 'battery_3_4';
			} else {
				batteryImage = 'battery_full';
			}

			var digits = new Array(0,0);
			if(IE5) {
				if(document.cookie && document.cookie.indexOf("HistoryCount") != -1) {
					window.history.HistoryCount = parseInt(document.cookie.substring(document.cookie.indexOf("HistoryCount=")+13,document.cookie.indexOf("HistoryCount=")+16));
				}
			}
			if(window.history.HistoryCount) {
				strHistory = parseInt(window.history.HistoryCount);
				if(strHistory > 99) {
					strHistory-= 100;
				}
				window.history.HistoryCount = parseInt(strHistory);

				if(window.history.HistoryCount > 9) {
					digits = window.history.HistoryCount.toString().split('');
				} else {
					digits[1] = window.history.HistoryCount;
				}
			}

			var adOutput = '';
			if(this.Adverts[this.currentNav]) {
				adOutput+= '<TR>\n' +
					'	<TD></TD>\n' +
					'	<TD COLSPAN="4" VALIGN="bottom"#HEIGHT#>\n' +
					'	<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n' +
					'	<TR>\n' +
					'		<TD COLSPAN="3"><IMG SRC="'+this.imagePath+'1px_'+this.styles[this.currentNav][2]+'.gif" WIDTH="'+(this.Adverts[this.currentNav][2]+2)+'" HEIGHT="1" BORDER="0"></TD>\n' +
					'	</TR>\n' +
					'	<TR>\n' +
					'		<TD><IMG SRC="'+this.imagePath+'1px_'+this.styles[this.currentNav][2]+'.gif" WIDTH="1" HEIGHT="'+this.Adverts[this.currentNav][3]+'" BORDER="0"></TD>\n' +
					'		<TD><A HREF="'+this.Adverts[this.currentNav][0]+'"><IMG SRC="'+this.Adverts[this.currentNav][1]+'" WIDTH="'+this.Adverts[this.currentNav][2]+'" HEIGHT="'+this.Adverts[this.currentNav][3]+'" BORDER="0"></A></TD>\n' +
					'		<TD><IMG SRC="'+this.imagePath+'1px_'+this.styles[this.currentNav][2]+'.gif" WIDTH="1" HEIGHT="'+this.Adverts[this.currentNav][3]+'" BORDER="0"></TD>\n' +
					'	</TR>\n' +
					'	<TR>\n' +
					'		<TD COLSPAN="3"><IMG SRC="'+this.imagePath+'1px_'+this.styles[this.currentNav][2]+'.gif" WIDTH="'+(this.Adverts[this.currentNav][2]+2)+'" HEIGHT="1" BORDER="0"></TD>\n' +
					'	</TR>\n' +
					'	<TR><TD COLSPAN="3" HEIGHT="25"></TD></TR>\n' +
					'	</TABLE>\n' +
					'	</TD>\n' +
					'</TR>\n';
				this.ROWSPAN++;
			}

			if(!IE5) {
				navigationOutput+= adOutput.replace(/#HEIGHT#/g,' HEIGHT="100%"');
				navigationOutput+= this.createCounter(digits);
				navigationOutput+= '	<TR><TD COLSPAN="5"><IMG SRC="'+this.imagePath+'1px_ffffff.gif" WIDTH="191" HEIGHT="9" BORDER="0"></TD></TR>\n';
			} else {
				navigationOutput+= '	</TABLE>\n';
				navigationOutput+= '	</TD>\n';
				navigationOutput+= '</TR>\n';
				navigationOutput+= '<TR>\n';
				navigationOutput+= '	<TD VALIGN="bottom">\n';
				navigationOutput+= '	<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n';

				navigationOutput+= adOutput.replace(/#HEIGHT#/g,' HEIGHT="100%"');
				navigationOutput+= this.createCounter(digits);
				navigationOutput+= '	<TR><TD COLSPAN="4" HEIGHT="100%"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="191" HEIGHT="15" BORDER="0"></TD></TR>\n';
				navigationOutput+= '	<TR><TD COLSPAN="4"><IMG SRC="'+this.imagePath+'1px_ffffff.gif" WIDTH="191" HEIGHT="9" BORDER="0"></TD></TR>\n';
				navigationOutput+= '	</TABLE>\n';
				navigationOutput+= '	</TD>\n';
				navigationOutput+= '</TR>\n';
			}
		}
		navigationOutput+= '</TABLE>\n';

		navigationOutput = navigationOutput.replace(/#ROWSPAN#/,this.ROWSPAN);

		navigation2Output = '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="190" BACKGROUND="'+this.backgroundImage+'" CLASS="norepeat">\n';
		navigation2Output+= '<TR>\n';
		navigation2Output+= '	<TD ROWSPAN="3"><IMG SRC="'+this.imagePath+'1px_ffffff.gif" WIDTH="1" HEIGHT="91" ALT=""></TD>\n';
		navigation2Output+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="10" HEIGHT="10" ALT=""></TD>\n';
		navigation2Output+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="72" HEIGHT="10" ALT=""></TD>\n';
		navigation2Output+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="98" HEIGHT="10" ALT=""></TD>\n';
		navigation2Output+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="9" HEIGHT="10" ALT=""></TD>\n';
		navigation2Output+= '</TR>\n';
		navigation2Output+= '<TR>\n';
		navigation2Output+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="9" HEIGHT="71" ALT=""></TD>\n';
		navigation2Output+= '	<TD VALIGN="top"><IMG SRC="'+this.imagePath+'nikon_logo.gif" WIDTH="72" HEIGHT="71" BORDER="0" ALT="Nikon"></TD>\n';
		if(this.currentNav==0) { //Added by matthew.elwin@akqa.com because need a different image for each randon homepage image
			navigation2Output+= '	<TD VALIGN="bottom" ALIGN="right"><IMG SRC="'+this.imagePath+'btn_navigation_'+this.currentNav+'_'+iPageScheme+'.gif" WIDTH="68" HEIGHT="15" BORDER="0" ALT="NAVIGATION" USEMAP="#NavigationMap"></TD>\n';
		} else {
			navigation2Output+= '	<TD VALIGN="bottom" ALIGN="right"><IMG SRC="'+this.imagePath+'btn_navigation_'+this.currentNav+'.gif" WIDTH="68" HEIGHT="15" BORDER="0" ALT="NAVIGATION" USEMAP="#NavigationMap"></TD>\n';
		}
		navigation2Output+= '	<TD><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="9" HEIGHT="71" ALT=""></TD>\n';
		navigation2Output+= '</TR>';
		navigation2Output+= '<TR><TD COLSPAN="4"><IMG SRC="'+this.imagePath+'clear.gif" WIDTH="189" HEIGHT="10" ALT=""></TD></TR>\n';
		navigation2Output+= '</TABLE>';

		if (useSTATIC) {
			// Do nothing, using 'navigationOutput' variable
			this.finalOutput+= navigationOutput;
		} else if (useDIV && isALL) {
			// Create IE4+ compliant Version of LH Nav
			this.navigation = new Object();
			this.navigation.outerHTML = '<DIV ID="NikonMenu" STYLE="{position:absolute; top:'+this.DEFAULT_TOP+'; left:'+this.DEFAULT_LEFT+'; width:190px; height:auto; background-color:'+this.backgroundColor+'; z-index:20; visibility:hidden; clip:rect(0,190,100%,1);}">\n';
			this.navigation.outerHTML+= navigationOutput;
			this.navigation.outerHTML+= '</DIV>\n';
			this.navigation.setLeft = function(strLeft) {
				document.all['NikonMenu'].style.left = strLeft;
			}
			this.navigation.hideMenu = function() {
				document.all['NikonMenu'].style.visibility = HIDE;
			}
			this.navigation.showMenu = function() {
				document.all['NikonMenu'].style.visibility = SHOW;
			}
			this.navigation.getHeight = function() {
				if(IE5 || IE55) {
					return document.all['NikonMenu'].offsetHeight;
				} else {
					return document.all['NikonMenu'].offsetHeight - 10;
				}
			}
			this.navigation.setHeight = function(sHeight) {
				if(IE5 || IE55) {
					document.all['NikonMenu'].style.height = sHeight;
				} else {
					document.all['NikonMenu'].style.height = sHeight - 9;
				}
			}
			this.finalOutput+= this.navigation.outerHTML;

			this.navigation2 = new Object();
			this.navigation2.outerHTML = '<DIV ID="NikonClosed" STYLE="{position:absolute; top:'+this.DEFAULT_TOP+'; left:'+(parseInt(this.DEFAULT_LEFT)+21)+'; width:150px; height:71px; z-index:19; visibility:hidden;}">\n';
			this.navigation2.outerHTML+= navigation2Output;
			this.navigation2.outerHTML+= '</DIV>\n';
			this.navigation2.setLeft = function(strLeft) {
				document.all['NikonClosed'].style.left = strLeft;
			}
			this.navigation2.hideMenu = function() {
				document.all['NikonClosed'].style.visibility = HIDE;
			}
			this.navigation2.showMenu = function() {
				document.all['NikonClosed'].style.visibility = SHOW;
			}
			this.finalOutput+= this.navigation2.outerHTML;
		}
		this.createMap();
		this.endOutput(false, removeBackground);
	}

	this.setMenuAndStyle = function(name, backgroundColor, dividerColor, backgroundWidth, linkHoverColor, location) {
		this.addStyle(name, backgroundColor, dividerColor, backgroundWidth, linkHoverColor, location);
		this.setMenu(location);
	}
	this.addDefaultStyle = function(name, backgroundColor, dividerColor, backgroundWidth, linkHoverColor) {
		this.DEFAULT_STYLE = new Array(name, backgroundColor, dividerColor, backgroundWidth, linkHoverColor);
	}
	this.addStyleAsDefault = function() {
		this.styles[this.styles.length] = this.DEFAULT_STYLE;
	}

	this.setImagesPath = function(URL) {
		if(URL.charAt(URL.length-1) != "/") {
			URL+="/";
		}
		this.imagePath = URL;
	}
	this.trackPosition = function() {
		this.endOutput(true);
		if (useSTATIC) {
			// do Nothing
		} else if (useDIV && isALL) {
			document.write('<DIV ID="trackPosition" STYLE="{position:absolute; height:auto; width:100%; visibility:hidden;}">');
			document.write('</DIV>');

			this.whiteSpace = new Object();
			this.whiteSpace.outerHTML = '<DIV ID="whiteSpace" STYLE="{position:absolute; z-index:-1; left:'+(parseInt(this.DEFAULT_WIDTH)-9)+'; top:'+this.DEFAULT_TOP+'; height:405; width:755; visibility:hidden; background-color:#FFFFFF;}">\n';
			this.whiteSpace.outerHTML+= '</DIV>';
			this.whiteSpace.setLeft = function(sLeft) {
				document.all['whiteSpace'].style.left = sLeft;
			}
			this.whiteSpace.setHeight = function(sHeight) {
				document.all['whiteSpace'].style.height = sHeight;
			}
			this.whiteSpace.setVisible = function() {
				document.all['whiteSpace'].style.visibility = SHOW;
			}
			document.write(this.whiteSpace.outerHTML);
		}
	}
	this.addAdvert = function(menu, url, img, width, height) {
		width = (width) ? width : 148;
		height = (height) ? height : 59;
		img = (img.indexOf("/") != -1) ? img : this.imagePath+img;
		this.Adverts[menu] = new Array(url, img, width, height);
	}
	this.disableScrolling = function() {
		this.scrollingEnabled = false;
	}

	/*
		CONFIG: Scrollbars
		This section is used for scrolling the Navigation up and down when more than 5
		items appear on a navigation at one time.
	*/
	var scrollInt = 0;
	var scrollingEnabled = true;
	var scrollItemsInList = 3;
	var scrollAreaHeights = new Array(15,29,43,58,72);
	var scrollBarHeight = 10;
	var scrollBarArea = scrollAreaHeights[scrollItemsInList-1];

	this.scrollInt = scrollInt;
	this.scrollingEnabled = scrollingEnabled;
	this.scrollItemsInList = scrollItemsInList;
	this.scrollBarHeight = scrollBarHeight;
	this.scrollBarArea = scrollBarArea;

	function calcPercent(myHeight, myTop) {
		var DivideBy = (myHeight - this.scrollBarArea) / myTop;
		var retVal = (this.scrollBarArea - this.scrollBarHeight - 24) / DivideBy;
		retVal = (Math.round(retVal)) ? Math.round(retVal) : 0;
		return retVal + 11;
	}
	function scrollNav(direction) {
		if(this.scrollInt == 0) {
			var delay = (isMac) ? 1 : 15;
			this.scrollInt = setInterval("javascript:NikonMenu.scrollNav("+direction+");",delay);
		}
		var scrollLayerHeight = parseInt( document.all['scrollLayer'+this.currentNav].offsetHeight );
		var scrollLayerTop = parseInt( document.all['scrollLayer'+this.currentNav].offsetTop );

		if(direction == -1) {
			if( (this.scrollBarArea - scrollLayerHeight) < scrollLayerTop) {
				document.all['scrollLayer'+this.currentNav].style.top = scrollLayerTop - 1;
			}
		} else {
			if( scrollLayerTop < 0) {
				document.all['scrollLayer'+this.currentNav].style.top = scrollLayerTop + 1;
			}
		}
		this.adjustScrollBar();
	}
	function adjustScrollBar() {
		var scrollLayerHeight = parseInt( document.all['scrollLayer'+this.currentNav].offsetHeight );
		var scrollLayerTop = parseInt( document.all['scrollLayer'+this.currentNav].offsetTop );
		var scrollBarTop = this.calcPercent(scrollLayerHeight, -scrollLayerTop);
		document.all['barLayer'+this.currentNav].style.top = scrollBarTop;
	}
	this.calcPercent = calcPercent;
	this.scrollNav = scrollNav
	this.adjustScrollBar = adjustScrollBar;


	this.endScroll = function() {
		clearInterval(this.scrollInt);
		this.scrollInt = 0;
	}

	return this;
}
window.onresize = function() {
	if (useSTATIC) {
	} else if (useDIV && isALL) {
		NikonMenu.PlaceNavigation();
	}
}

// flash implementation code starts here
//************************************************************

var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var maxVersion = 6;
var actualVersion = 0;
var hasRightVersion = false;

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
  document.write('</SCR' + 'IPT\> \n');
}

//do a check on every page that incluides the dynamic menu!!
if (!detectFlash(5)){
	document.location.replace('/flashUpgrade.htm');
}

function detectFlash(requiredVersion) {
  if (navigator.plugins) {
    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {

      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

      flash2Installed = flashVersion == 2;
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion >= 6;
    }
  }
  for (var i = 2; i <= maxVersion; i++) {
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  //alert('actualVersion:' + actualVersion);
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;
  if (actualVersion < requiredVersion) {
	hasRightVersion = false;
  } else {
  	hasRightVersion = true;
  }
  return hasRightVersion;
}

function outputFlash(flashFile, width, height, version) {

	flashFile = 'images/' + flashFile + '.swf';
	version = (version) ? version : 6;

	var flashOutput = '';
	//Additional flash check made everytime a flash movie is outputted. Although not strictly necessary because users can't go anywhere without Flash
	if (actualVersion >= version) {
		flashOutput+= '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		flashOutput+= ' WIDTH="'+width+'" HEIGHT="'+height+'" CODEBASE="http://active.macromedia.com/flash5/cabs/swflash.cab#version='+version+',0,0,0">';
		flashOutput+= '<PARAM NAME="MOVIE" VALUE="'+flashFile+'">';
		flashOutput+= '<PARAM NAME="PLAY" VALUE="true">';
		flashOutput+= '<PARAM NAME="LOOP" VALUE="true">';
		flashOutput+= '<PARAM NAME="QUALITY" VALUE="best">';
		flashOutput+= '<EMBED SRC="'+flashFile+'" WIDTH="'+width+'" HEIGHT="'+height+'" MENU="false" LOOP="true"';
		flashOutput+= ' QUALITY="BEST" BORDER="0" swliveConnect="true" TYPE="application/x-shockwave-flash"';
		flashOutput+= ' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
		flashOutput+= '</EMBED>';
		flashOutput+= '</OBJECT>';
		document.write(flashOutput);
	} else {
		document.location.href = '/flashUpgrade.htm';
	}
}

// flash implementation code ends here
//************************************************************