/*******************************
* This script builds the menu  *
*******************************/

<!--
	var ns4 = (document.layers)? true:false;
   	var ie4 = (document.all)? true:false;

var logCount = 1;

var flashRunning = false;
var appletRunning = false;

var timeoutId = null;	// variable used to help in hiding menus
	
var navy = -300;  //variables for menu position
var navx = 0; 	

var menuCount = 1;
var nsMenuLoaded = false;
var nsSensorCreated = false;

var overItem = false;

var menuArray = new Array();

var partOfArray = new Array();
var elementArray = new Array();
var linkArray = new Array();
var tempResult = new Array();
var openedArray = new Array();
var toOpenArray = new Array();
var nsWriteArray = new Array(); 

flashNotify("null");
appletNotify("null");

/*********These variables define generic variables for element states*************/

var elemBackGround = "#333366";  // starting background colour of elemenets
var elemRollOver = "#999999";	// rollover colour of elements
var elemFont = "Verdana"; 	// the font for menus ie Arial,Comic Sans MS, Gill Sans, Brush Script
var elemFontSze = 11;		// font size for menus
var elemFontColour = "white";  	// font colour
var elemFontOver = "white";  	// font colour
var elemFontOff = "white";  	// font colour
var elemBorderStyle = "solid"  	// choices "none" "ridge" "solid" "double" "inset" "outset" "groove"
//var elemPadding = 0		// IE padding - This has been set to 0 in order to handle IE4 browsers
var elemPadding = 2		// IE padding - This has been set to 0 in order to handle IE4 browsers
var elemBorderWidth = 1		// NS padding
var nsFontWeight = 0 		//used for Netscape (ie bold) range 100-900

var sensorWidth = 800;		// sensor width size
var sensorHeight = 200;		// sensor height size
var sensorLeft = 0;		// sensor x position
var sensorTop = 110;		// sensor y position

var menuIndex = 566;
var sensorIndex = 565;

var containerLeft = 0;		// moves the whole menu system on the x-axis
var containerTop = 0;		// moves the whole menu system on the y-axis
//var pageType = "template";

// Browser specific vars
if(ie4){
elemFontSize = elemFontSze - 1;
var menuDepth = 99}

if(ns4){
elemFontSize = elemFontSze - 3;
var menuDepth = 94}




/*****************End of generic variables**********************************/

// Capture Window errors
window.onerror = windowError;

if(ns4){  
	document.open();
	document.writeln('<STYLE TYPE="text/css">');
	document.writeln('.styleon {color:'+elemBackGround+'; width:300px ; border-width:'+elemBorderWidth+'px;border-color:000000;border-style:solid;padding:0%}');
	document.writeln('.styleoff {color:'+elemRollOver+'; width:300px ;border-width:'+elemBorderWidth+'px;border-color:000000;border-style:solid;padding:0%}');
	document.writeln('</STYLE>');
	document.close();
	}

function initMenus() 
{
	if(ie4){
		createContainerAndSensor();
	}
	getConf();
  	if(ns4)	{
		nsWriteLayers();
	}
}


function getConf(){

	if(ns4){
		sensortext = "";
		sensortext += "<LAYER ID='thesensor' width="+sensorWidth+"; height="+sensorHeight+"; z-index="+sensorIndex+"; left="+sensorLeft+"; top="+sensorTop+"></LAYER>";
		nsWriteArray[nsWriteArray.length] = sensortext;
	}
		
	while(eval("window.vxmenu" + menuCount)){
		temper = eval("window.vxmenu" + menuCount);
		menuArray[menuArray.length] = "vxmenu"+menuCount;
		menuMake(temper);
		menuCount++;
	}	
	if (ie4)	{
		// the menus will now have been built, therfore, activate them
		// Fernando showHideLayers('menu', 'menuCover');
	}	
}

function createContainerAndSensor(){	//for ie4 only
	htmltext = "<DIV ID='container' STYLE='position:absolute; z-index:"+sensorIndex+"; left:"+containerLeft+"; top:"+containerTop+"'></DIV>";
	window.document.body.insertAdjacentHTML("AfterBegin",htmltext);
	}

function menuMake(theMenu){ 

	itemcount = 1;
	xposit = theMenu[theMenu.length - 5]; 
	if(ie4){if((theMenu[theMenu.length - 1]) == "vert"){yposit = theMenu[theMenu.length - 4]-3+menuDepth;}//adjustment for x axis
		else
			{yposit = theMenu[theMenu.length - 4];}
	xposit+=2;
	} 
	if(ns4){
		if((theMenu[theMenu.length - 1]) == "vert"){yposit = theMenu[theMenu.length - 4]+2+menuDepth;} //adjustment for x axis
			else
			{yposit = theMenu[theMenu.length - 4];}
	} 
	
	
	for(cont = 0; cont < (theMenu.length - 5); cont+=5){

		if((theMenu[theMenu.length - 1]) == "horz"){

			elementBuild(theMenu[cont],theMenu[cont+1],theMenu[cont+3],theMenu[cont+4],xposit,yposit,"horz",theMenu[theMenu.length - 3],theMenu[theMenu.length - 2],theMenu[cont+2]);
			xposit+= theMenu[theMenu.length - 3];

			}
		if((theMenu[theMenu.length - 1]) == "vert"){

			elementBuild(theMenu[cont],theMenu[cont+1],theMenu[cont+3],theMenu[cont+4],xposit,yposit,"vert",theMenu[theMenu.length - 3],theMenu[theMenu.length - 2],theMenu[cont+2]);
			if(ie4){
				if(theMenu[theMenu.length - 3] <= 140){yposit+= theMenu[theMenu.length - 2];}
				if(theMenu[theMenu.length - 3] >= 141){yposit+= theMenu[theMenu.length - 2]+elemPadding;}
				}
			if(ns4){yposit+= theMenu[theMenu.length - 2]+(elemBorderWidth*2);}	
			}

		itemcount++;
	}
}


function elementBuild(elTitle, elemLink, baseLink, type, xposit, yposit ,elemtype,elemWth,elemHt,hilite){  //This function builds each element for IE only

	logElement("vxmenu"+menuCount,"vxmenu"+menuCount+"_"+itemcount, elemLink);

	if(ie4){
		elemHt = elemHt + 3;
		htmlstring = "";
		if(checkLinkType(type) == "html") {htmlstring +="<A HREF='"+elemLink+"' onMouseOver='changeColor(\"vxmenu"+menuCount+"_"+itemcount+"\",\""+hilite+"\"); showMenu(\"vxmenu"+menuCount+"\");' onMouseOut='changeBack(\"vxmenu"+menuCount+"_"+itemcount+"\",\""+hilite+"\"); tryToCloseMenus()'>"; menuIndex = menuIndex + 1;}
		if(checkLinkType(type) == "menu") {htmlstring +="<A HREF='#' onMouseOver='changeColor(\"vxmenu"+menuCount+"_"+itemcount+"\",\""+hilite+"\"); showMenu(\""+elemLink+"\");' onMouseOut='changeBack(\"vxmenu"+menuCount+"_"+itemcount+"\",\""+hilite+"\"); tryToCloseMenus()'>"; menuIndex = menuIndex + 1;}
		if(checkLinkType(type) == "htmlmenu") {htmlstring +="<A HREF='"+baseLink+"' onMouseOver='changeColor(\"vxmenu"+menuCount+"_"+itemcount+"\",\""+hilite+"\"); showMenu(\""+elemLink+"\");' onMouseOut='changeBack(\"vxmenu"+menuCount+"_"+itemcount+"\",\""+hilite+"\"); tryToCloseMenus()'>"; menuIndex = menuIndex + 1;}
		if(checkLinkType(type) == "function") {htmlstring +="<A HREF='#' onClick='"+elemLink+"' onMouseOver='changeColor(\"vxmenu"+menuCount+"_"+itemcount+"\",\""+hilite+"\"); showMenu(\"vxmenu"+menuCount+"\");' onMouseOut='changeBack(\"vxmenu"+menuCount+"_"+itemcount+"\",\""+hilite+"\"); tryToCloseMenus()'>"; menuIndex = menuIndex + 1;}

		htmlstring += "<DIV ALIGN='LEFT' ID='vxmenu"+menuCount+"_"+itemcount;
		htmlstring += "' STYLE='position:absolute; cursor:hand; border-color:000000; border-style:"+elemBorderStyle+"; border-width:"+(elemBorderWidth)+"; padding:"+elemPadding+"%; width:"+elemWth+"; height:"+(elemHt)+"; clip: rect(0 "+(elemWth)+" "+(elemHt+elemPadding+elemBorderWidth)+" 0); text-decoration:none; z-index:"+menuIndex+"; left:"+xposit+"; top:"+yposit;
		htmlstring += ";font-weight:none; background-color:"+elemBackGround+";font-size:"+elemFontSize+"; font-family:\""+elemFont+"\";color:\""+elemFontColour+"\"'>";
		htmlstring +=elTitle+ "</DIV></A>";
	  
		window.document.all["container"].insertAdjacentHTML("AfterBegin",htmlstring);
		document.all["vxmenu"+menuCount+"_"+itemcount].style.visibility = "hidden";
		}

	if(ns4){

		htmlstring = "";
		htmlstring += '<LAYER ID="vxmenu'+menuCount+'_'+itemcount+'" TOP='+yposit+' LEFT='+xposit+' WIDTH='+elemWth+' HEIGHT='+elemHt+' VISIBILITY="hide" BGCOLOR='+elemBackGround+' '; 

		if(checkLinkType(type) == "html") {htmlstring += 'onMouseOver="changeColor(\'vxmenu'+menuCount+'_'+itemcount+'\',\''+hilite+'\',\''+elemFont+'\',\''+elemFontColour+'\','+elemFontSize+',\''+elTitle+'\'); showMenu(\'vxmenu'+menuCount+'\')" onMouseOut="changeBack(\'vxmenu'+menuCount+'_'+itemcount+'\',\''+hilite+'\',\''+elemFont+'\',\''+elemFontColour+'\','+elemFontSize+',\''+elTitle+'\'); tryToCloseMenus()" onFocus=\'callPage(\"'+elemLink+'\")\'>'; }
		if(checkLinkType(type) == "menu") {htmlstring += 'onMouseOver="changeColor(\'vxmenu'+menuCount+'_'+itemcount+'\',\''+hilite+'\',\''+elemFont+'\',\''+elemFontColour+'\','+elemFontSize+',\''+elTitle+'\'); showMenu(\''+elemLink+'\')" onMouseOut="changeBack(\'vxmenu'+menuCount+'_'+itemcount+'\',\''+hilite+'\',\''+elemFont+'\',\''+elemFontColour+'\','+elemFontSize+',\''+elTitle+'\'); tryToCloseMenus()"\'>';}
		if(checkLinkType(type) == "htmlmenu") {htmlstring += 'onMouseOver="changeColor(\'vxmenu'+menuCount+'_'+itemcount+'\',\''+hilite+'\',\''+elemFont+'\',\''+elemFontColour+'\','+elemFontSize+',\''+elTitle+'\'); showMenu(\''+elemLink+'\')" onMouseOut="changeBack(\'vxmenu'+menuCount+'_'+itemcount+'\',\''+hilite+'\',\''+elemFont+'\',\''+elemFontColour+'\','+elemFontSize+',\''+elTitle+'\'); tryToCloseMenus()" onFocus=\'callPage(\"'+baseLink+'\")\'>';}
		if(checkLinkType(type) == "function") {htmlstring += 'onMouseOver="changeColor(\'vxmenu'+menuCount+'_'+itemcount+'\',\''+hilite+'\',\''+elemFont+'\',\''+elemFontColour+'\','+elemFontSize+',\''+elTitle+'\'); showMenu(\'vxmenu'+menuCount+'\')" onMouseOut="changeBack(\'vxmenu'+menuCount+'_'+itemcount+'\',\''+hilite+'\',\''+elemFont+'\',\''+elemFontColour+'\','+elemFontSize+',\''+elTitle+'\'); tryToCloseMenus()" onFocus=\''+elemLink+'; closeAllMenus()\'>';}

		htmlstring += '<SPAN CLASS="styleon"><FONT FACE="'+elemFont+'" COLOR=\''+elemFontColour+'\' POINT-SIZE='+elemFontSize+'><B>'+elTitle+'</B></FONT></SPAN></LAYER>';

		nsWriteArray[nsWriteArray.length] = htmlstring;
		}

		//window.status = "Element "+logCount+" created";
		logCount++;
	}

// This version correctly passes information into the 'bottom' frame
function callPage(elemLink){ //Netscape only
	// Change made by SA/JH to fully qualify where a page should go back to, forces the parent page to be displayed
	// IMPORTANT FOR NS ONLY
        newURL = "";
	finalURL = "";
	finalURL = elemLink;
//	alert(finalURL);
	newURL += "" + finalURL;
//	alert(newURL);
        top.parent.location.href = (newURL);
}

function nsWriteLayers(){ 

	if(!nsMenuLoaded){ 

		document.layers["container"].document.open();

		for(counter = 0; counter < nsWriteArray.length; counter++){
			buildLayer = nsWriteArray[counter];
			document.layers["container"].document.write(buildLayer);
		}
		document.layers["container"].document.close();
		nsMenuLoaded = true;
		menuready = true;
		sensorCreated = true;
		showHideLayers('menu', 'menuCover');
	}			
}

function changeColor(itemToChange,change,nsFontFace,nsColor,nsPointSize,nsTitle){ 
	if(change=="hilite"){ 
			if(ie4){
				document.all[itemToChange].style.backgroundColor = elemRollOver; 
				document.all[itemToChange].style.color = elemFontOver ;
				}
	
			if(ns4){ 
				changeString = '';
				changeString +='<SPAN CLASS="styleoff"><FONT FACE="'+nsFontFace+'" COLOR=\''+elemFontOver+'\' POINT-SIZE='+nsPointSize+'><B>'+nsTitle+'</B></FONT></SPAN>';
				document.layers["container"].document.layers[itemToChange].document.open();
				document.layers["container"].document.layers[itemToChange].document.write(changeString);
				document.layers["container"].document.layers[itemToChange].document.close();
				document.layers["container"].document.layers[itemToChange].bgColor = elemRollOver;
				}		
			}

	if(change=="nohilite"){
			if(ie4){
				document.all[itemToChange].style.color = elemFontOver ;
				}	
			if(ns4){
				changeString = '';
				changeString +='<SPAN CLASS="styleon"><FONT FACE="'+nsFontFace+'" COLOR=\''+elemFontOver+'\' POINT-SIZE='+nsPointSize+'><B>'+nsTitle+'</B></FONT></SPAN>';
				document.layers["container"].document.layers[itemToChange].document.open();
				document.layers["container"].document.layers[itemToChange].document.write(changeString);
				document.layers["container"].document.layers[itemToChange].document.close();
				}		
			}
			overItem = true;
		}

function changeBack(itemToChange,change,nsFontFace,nsColor,nsPointSize,nsTitle){
	if(change=="hilite"){
		if(ie4){
			document.all[itemToChange].style.backgroundColor = elemBackGround;
	   		document.all[itemToChange].style.color = elemFontOff ; 
			}

			if(ns4){
				changeString = '';
				changeString +='<SPAN CLASS="styleoff"><FONT FACE="'+nsFontFace+'" COLOR=\''+elemFontOff+'\' POINT-SIZE='+nsPointSize+'><B>'+nsTitle+'</B></FONT></SPAN>';
				document.layers["container"].document.layers[itemToChange].document.open();
				document.layers["container"].document.layers[itemToChange].document.write(changeString);
				document.layers["container"].document.layers[itemToChange].document.close();
				document.layers["container"].document.layers[itemToChange].bgColor = elemBackGround;
				}
		}

	if(change=="nohilite"){
			if(ie4){
				document.all[itemToChange].style.color = elemFontOff ;
				}	
			if(ns4){
				changeString = '';
				changeString +='<SPAN CLASS="styleon"><FONT FACE="'+nsFontFace+'" COLOR=\''+elemFontOff+'\' POINT-SIZE='+nsPointSize+'><B>'+nsTitle+'</B></FONT></SPAN>';
				document.layers["container"].document.layers[itemToChange].document.open();
				document.layers["container"].document.layers[itemToChange].document.write(changeString);
				document.layers["container"].document.layers[itemToChange].document.close();
				}
			}
			overItem = false;
	}

function showMenu(menuToShow){


		// Required to show container
		if (ns4)	{
			document.layers["container"].visibility = "show";			
		}
		if(flashExist){scrollTo(0,0);}
		navy = containerTop;
		cleanUpMenus(menuToShow);
		temper = eval("window."+menuToShow); 
			counter = 0;		
			for(cont = 0; cont < (temper.length - 5); cont+=5){
				counter++
				if(ie4){
					document.all[menuToShow+"_"+counter].style.visibility = "visible";
				}
				if(ns4)	{
					document.layers["container"].document.layers[menuToShow+"_"+counter].visibility = "show";
				}
			}
		}

function cleanUpMenus(menuItem){
	openedArray.length = 0;
		for(count = 0; count < tempResult.length; count++){
				openedArray[count] = tempResult[count];
				}
		tempResult.length = 0;
		checkForLink(menuItem);

	toOpenArray.length = 0;
		for(count = 0; count < tempResult.length; count++){
				toOpenArray[count] = tempResult[count];
				}
		
		for(stepthru = 0; stepthru < openedArray.length; stepthru++){
				hidemenu = false;
				for(count = 0; count < toOpenArray.length; count++){
					if(openedArray[stepthru] == toOpenArray[count]){hidemenu = true;}
				}
				if(!hidemenu){hideMenu(openedArray[stepthru]);}
		}		
	}

function hideMenu(menuToShow){ 
	temper = eval("window."+menuToShow);
	counter = 0;		
	for(cont = 0; cont < (temper.length - 5); cont+=5){
		counter++
		if(ie4 && (menuToShow+"_"+counter)){
			if(document.all[menuToShow+"_"+counter].style.visibility != "hidden"){
				document.all[menuToShow+"_"+counter].style.visibility = "hidden";
			}
		}
		if(ns4 && (menuToShow+"_"+counter));	{
			if(ns4){
				if(document.layers["container"].document.layers[menuToShow+"_"+counter].visibility != "hide");
			}
			if(ns4){
				document.layers["container"].document.layers[menuToShow+"_"+counter].visibility = "hide";
			}
		}
	}
}



function checkLinkType(teststring){   //this returns true if the link is a html page, returns false if link open another menu


	if(teststring=="1"){outPutRes = "html";}

	if(teststring=="2"){outPutRes = "menu";}

	if(teststring=="3"){outPutRes = "function";}

	if(teststring=="4"){outPutRes = "htmlmenu";}

return outPutRes;
}

function logElement(partOf,anElement,aLink){
		//window.status = "Element "+logCount+" created";
		partOfArray[partOfArray.length] = partOf;
		elementArray[elementArray.length] = anElement;
		linkArray[linkArray.length] = aLink;
		//logCount++;
		}

function closeAllMenus(){  //called by the sensor to close all menu's 
		if(!overItem){
			for(acount = 0; acount < menuArray.length; acount++){
				if(menuArray[acount]){hideMenu(menuArray[acount]);} 
				}
			navy = -300;
			// Required to hide container layer after hiding all other menus
			if(ns4)	{
				document.layers["container"].visibility = "hide";
			}
		}			
}

function checkForLink(menuToCheck){	////alert("checked");
	tempResult[tempResult.length] = menuToCheck;	
	checkingLinkArrays(menuToCheck);
 }

function checkingLinkArrays(menuCheck){
	for(checkCount=0; checkCount < linkArray.length; checkCount++){
		if(menuCheck == linkArray[checkCount]){
			tempResult[tempResult.length] = partOfArray[checkCount]; 
			checkingLinkArrays(partOfArray[checkCount]);			
			} 
		}
	}

function offSensor(e){ 
		if(menuready){
		setTimeout("closeAllMenus();",500);
			}
		}

function writeNsLayers(){
	document.layers["container"].document.open();
	document.layers["container"].document.write('<H1>THIS WORKS</H1>');
	document.layers["container"].document.close();	
	}

function tryToCloseMenus()	{
	timeoutId = setTimeout("closeAllMenus()",5);
}

function showHideLayers(layerToShow, layerToHide) {
	if (ns4)	{
		eval('document.'+layerToShow+'.visibility="visible"');
		eval('document.'+layerToHide+'.visibility="hide"');
	}
	else
	if (ie4)	{
		eval('document.all.'+layerToShow+'.style.visibility="visible"');
		eval('document.all.'+layerToHide+'.style.visibility="hidden"');
	}
}

function windowError(message,url,line)	{
	//alert("Message:- " + message + " URL:- " + url + " Line:- " + line + "This message will be replaced with something else when going live");
	return true;
}

/**********taken from current javascript*****************/

function reloadPage(){if(ns4)location.reload();}

function flashNotify(name){if(name == true){flashExist = true; 
					    templocation = location;}
			  else
				{flashExist = false;}
		}
	
			  
function hideFlash(flashname){
	flashRunning = false;
	if(ns4){document.layers[flashname].visibility = "hide";}
	if(ie4){document.all[flashname].style.visibility = "hidden";}
}

function showFlash(flashname){
	flashRunning = true
		if(ns4){document.layers[flashname].visibility = "show";}
		if(ie4){document.all[flashname].style.visibility = "visible";}
	}

function appletNotify(appname){if(appname == "null"){appletExist = false;
						     appletRunning = false;}
				else					
					{appletExist = true;
					 appletRunning = true;
			         	 appletLayer = appname;}
			      }

function hideApplet(appname){
	appletRunning = false;
	if(ns4){document.layers[appname].visibility = "hide";}
	if(ie4){document.all[appname].style.visibility = "hidden";}
	}

function showApplet(appname){
	appletRunning = true
		if(ns4){document.layers[appname].visibility = "show";}
		if(ie4){document.all[appname].style.visibility = "visible";}
		
	}

function pageType(pagekind){parent.frames["vxmenu"].pageType(pagekind);}

function checkMenu(){
	if(1==1) {
		if(ie4){
			y = 0 + document.body.scrollTop;
			x = document.body.scrollLeft;   //46 + document.body.scrollLeft;
			document.all["container"].style.top = y + navy;
			document.all["container"].style.left = x + containerLeft;
			}
		if(ns4){
			y = 0 + window.pageYOffset;
			x = window.pageXOffset;  //46 + window.pageXOffset;
			document.layers["container"].top = y + navy;
			document.layers["container"].left = x + navx;
			}
		}
	setTimeout("checkMenu()",10);
	}

/**************************end of current javascript functions**********/

//-->

 
