//------------------------------------------------------------------------------
//	Program:	scripts/dropdown.js
//	Function:	functions to handle the normal drop down menus.
//	Version:	1.0
//
//	Version History
//
//	V#    Date        Author          Reason
//	==    ====        ======          ======
//	1.0   20/08/2001	Bill Hicks	    New Program
//------------------------------------------------------------------------------
function showDDNav(menuName)
{
	var theObj;
	if(br=="N")
	{
		theObj = document.layers[menuName];
 		if (theObj)
		{
			if(theObj.visibility=='hide')
				theObj.visibility = 'show';
		}
	}
	else if(br=="IE")
	{
		theObj=document.all[menuName];
		if (theObj)
		{
			if (theObj.style)
			{
				if(theObj.style.visibility=='hidden')
					theObj.style.visibility = 'visible';
			}
		}
	}
	else
		return;
}


// hides the drop down menu 

function hideDDNav(menuName)
{
	var theObj;
	if(br=="N")
	{
		theObj = document.layers[menuName];
		if (theObj)
		{
			if(theObj.visibility=='show')
				theObj.visibility = 'hide';
		}
	}
	else if(br=="IE")
	{
		theObj=document.all[menuName];
		if (theObj)
		{
		if (theObj.style)
			{
			if(theObj.style.visibility=='visible')
				theObj.style.visibility = 'hidden';
			}
		}
	}
	else{return}
}


// hides drop down menu when menu is active

function hideDiv(divID)
{
	if(br=="N"){}
	else if(br=="IE")
	{
		theObj=document.all[divID];
		// calculate active size of menu
		leftDiv=theObj.offsetLeft +2;
		rightDiv=theObj.offsetLeft + theObj.clientWidth -2;
		topDiv=theObj.offsetTop +2;
		bottomDiv=theObj.offsetTop + theObj.clientHeight -2;
		if (window.event.clientY > bottomDiv || window.event.clientY < topDiv || 
		    window.event.clientX < leftDiv || window.event.clientX > rightDiv)
			theObj.style.visibility = 'hidden';
	}
	else{}
}


// highlight menuitem

function divOver(tdID)
{
	if(br=="N"){}
	else if(br=="IE")
	{
		theObj=document.all[tdID];
		if(theObj.style.backgroundColor=backgroundColour)
		{
			theObj.style.backgroundColor=highlightBColour;
			theObj.style.color=highlightTColour;
		}
	}
	else{}
}

// highlight off menuitem

function divOut(tdID)
{
	if(br=="N"){}
	else if(br=="IE")
	{
		theObj=document.all[tdID];
		if(theObj.style.backgroundColor=highlightBColour)
		{
			theObj.style.backgroundColor=backgroundColour;
			theObj.style.color=textColour;
		}
	}
	else{}
}


// highlight on menuitem in netscape

function menuOver(layerID, nestLayerID)
{
	var theMenu;
	var theAnchor;
	theMenu = document.layers[layerID].document.layers["x"+nestLayerID];
	theMenu.bgColor="#" + highlightBColour;
//alert(layerID+nestLayerID);
//	theAnchor = document.layers[layerID].document.anchors[layerID+nestLayerID];
//	theAnchor.color="#" + highlightTColour;
}


// highlight off menuitem in netscape

function menuOut(layerID, nestLayerID)
{
	var theMenu;
	theMenu = document.layers[layerID].document.layers["x"+nestLayerID];
	theMenu.bgColor="#" + backgroundColour; 
	theMenu.color="#" + textColour;
}

// build the divs for IE

var tdID = 0
function doDiv(divID, x, divLeft, divTop, isMaint, minWidth)
{
	var dir = imageDir(isMaint);
	objDiv = "<div id='" + divID + "' style='position:absolute; left:"+ divLeft +"px; top:"+ divTop +"px; z-index:3; visibility:hidden;' onMouseover=\"showDDNav('"+ divID +"')\"  onMouseout=\"hideDiv('" + divID + "')\">";

	objDiv += "<table border='0' cellspacing='0' cellpadding='0'>"
	objDiv += "<tr class='panel'>"
	objDiv += 	"<td width='1' bgcolor='#f3f3fb'></td>"
	objDiv += 	"<td width='11'></td>"
	objDiv += 	"<td width='" + minWidth + "'>";

		
	for (y = 0; menuData[x][y] != null; y++)
	{
		if (menuData[x][y][0] != null)
		{
			objDiv += "<span class='menu' onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">";
			objDiv += "<div id='x" + tdID + "' style=\"position:relative; background-color:" + backgroundColour + "; \" onMouseover=\"divOver('"+'x' + tdID+"')\" onMouseout=\"divOut('"+'x' + tdID+"')\">";
			objDiv +=  menuData[x][y][0] +"</div></span>";
			tdID = tdID +1;
		}
	}

	objDiv += 	"</td>";
	objDiv += 	"<td width='11'></td>";
	objDiv += 	"<td width='1' bgcolor='#f3f3fb'></td>";
	objDiv += "</tr>";
	objDiv += "<tr>";
	objDiv +=		"<td width='1'></td>"
	objDiv +=		"<td width='11' height='10' background='"+dir+"/cnr_lt_bottomleft.gif'></td>";
	objDiv += 	"<td class='panel' height='10'>";
	objDiv += 		"<table border='0' cellspacing='0' cellpadding='0' width='100%' height='10'>";
	objDiv += 			"<tr><td height='9'></td></tr>";
	objDiv += 			"<tr><td height='1' bgcolor='#f3f3fb'></td></tr>";
	objDiv += 		"</table>";
	objDiv +=		"</td>";
	objDiv += 	"<td width='11' height='10' background='"+dir+"/cnr_lt_bottomright.gif'></td>";
	objDiv += 	"<td width='1'></td>"
	objDiv += "</tr>";
	objDiv += "</table>";

	objDiv +="</div>"
	
	document.write(objDiv);
//	alert(objDiv);
}


// build the layers for netscape

function doLayer(layerID, x, layerLeft, layerTop, isMaint, layerWidth)
{
	var dir = imageDir(isMaint);
	var nestLayerID=0

	if(navigator.platform.indexOf("Win") < 0)
	{
		layerInc=14;
		layerStyle="menu";
	}
	else	// this bit must be for Mac
	{
		layerInc=14;
		layerStyle="menu";
	}
		
	objDiv = "<layer id='"+ layerID +"' width="+layerWidth+" LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('"+ layerID +"')\" onmouseout=\"hideDDNav('"+layerID +"')\">";
	
	var nestTop=2;
	for (y = 0; menuData[x][y] != null; y++)
	{
		if(menuData[x][y][0] != null)
		{
			objDiv += "<layer id='x"+nestLayerID+"' bgcolor='"+backgroundColour+"' width="+layerWidth+" clip='0,0,"+layerWidth+",14' class='"+ layerStyle +"' HEIGHT=13 TOP="+ nestTop +" onmouseover=\"menuOver('"+layerID+"','"+nestLayerID+"')\" onmouseout=\"menuOut('"+layerID+"','"+nestLayerID+"')\">"
//			objDiv += "<img src='"+dir+"/1x1dk.gif' width='1' height='" + layerInc + "'>";
			objDiv += "<img src='"+dir+"/1x1trans.gif' width='10'>";
			objDiv += "<a name='"+layerID+nestLayerID+"' href=javascript:gotoUrl('"+menuData[x][y][1]+"')>" + menuData[x][y][0] + "</a>";
			objDiv += "</layer>"

			nestLayerID++;
			nestTop += layerInc;
		}
	}
	objDiv += "<layer id='x"+nestLayerID+"' width="+layerWidth+" TOP="+ nestTop + ">";
	objDiv += "<img src='"+dir+"/cnr_lt_bottomleft.gif'>";
	objDiv += "<layer id='x"+(nestLayerID+1)+"' bgcolor='"+backgroundColour+"' height=10 width="+(layerWidth-22)+">";
	objDiv +="</layer>";
	objDiv += "<img src='"+dir+"/1x1trans.gif' width="+(layerWidth-22)+" height=10>";
	objDiv += "<img src='"+dir+"/cnr_lt_bottomright.gif'>";
	objDiv +="</layer>";
	objDiv +="</layer>";

	document.write(objDiv);
}