/*
Version 9.2.9
*/

var parentObj = (isFrames) ? parent.document.body : window;
parentObj.onload = setup;


var margin = 5;

var activeMenu = null;
var mousePointerMenu = null;

var doc = null;
var bodyFrame = null;
var framesPrefix = "";

var rootMenu;
var IDs = 0;

var rowIDs = 0;
var activeRowId = -1;

window.onerror = function () { return true; }

function setup ()
{
	if (rootMenu != null) {
		return;
	}

	if (isFrames)
	{
		bodyFrame = eval("parent.frames." + mainFrName);
		if (bodyFrame && bodyFrame.document && bodyFrame.document.body) {
			doc = bodyFrame.document;
		}
	}	

	if (!doc)
		doc = document;

	if (isFrames && window && window.frameElement)
	{
		if (window.frameElement.name == "NAV")
		{
			framesPrefix = "parent.frames.NAV.";
		}
		else if (window.frameElement.name == "SUBNAV")
		{
			framesPrefix = "parent.frames.SUBNAV.";
		}
		else {
			framesPrefix = "parent.frames." + window.frameElement.name + ".";
		}
	}

	menuArray = new Array ();
	activeMenu = null;
	activeSubMenu = null;

	rootMenu = new Menu();
	setMenuColours (rootMenu, new Array(fntCol, overFnt, backCol, overCol, borCol, separatorCol));
	rootMenu.hasChildren = true;
	createTopLevel ("arMenu", rootMenu);

}

function createTopLevel(arrayName, rootMenu) {
	var i=1;
	var topLevelArray;

	for (i=1; ; i++) {
		try {
			eval(arrayName + i);
		}
		catch (e) {
			break;
		}
		createMenus(arrayName + i, rootMenu, i);
		rootMenu.subMenus[i-1].isChild = false;
	}
}

function createMenus (itemName, baseMenu, index)
{
	var i;
	try {
		var sectionMenu = eval(itemName);
	}
	catch (e) {
		return (null);
	}
	var itemCount=1;

	var menu = new Menu(index);
	menu.parent = baseMenu;
	baseMenu.subMenus[baseMenu.subMenus.length] = menu;
	
	setMenuColours (menu, sectionMenu);
	menu.startHTML = getDivHTML (menu.tableIdMarker + menu.ID, menu);

	for (var x = 6; x < sectionMenu.length; )
	{
		var caption = sectionMenu [x++];
		var onClick = sectionMenu [x++];
		var hasChildren = sectionMenu [x++];
		if (hasChildren) {
			menu.hasChildren = true;
		}

		if (caption != "" || onClick != "") {
			var newSub = null;
			if (menu.hasChildren) {
				newSub = createMenus(itemName + "_" + itemCount, menu, itemCount )
				if (newSub != null) {
					menu.subMenus[menu.subMenus.length] = newSub;
				}
			}

			addMenuItem (menu, caption, "", onClick, newSub, (x >= sectionMenu.length));
			itemCount +=1;
		}
	}
	return menu;
}

function setMenuColours(menu, sectionMenu) {
	var x = 0;
	menu.fntCol = sectionMenu[x++];
	menu.overFnt = sectionMenu[x++];
	menu.backCol = sectionMenu[x++];
	menu.overCol = sectionMenu[x++];
	menu.borCol = sectionMenu[x++];
	menu.separatorCol = sectionMenu[x++];

	if (menu.fntCol == "") {
		if (menu.parent != null) {
			menu.fntCol = menu.parent.fntCol;
		}
		else {
			menu.fntCol = fntCol;
		}
	}
	if (menu.overFnt == "") {
		if (menu.parent != null) {
			menu.overFnt = menu.parent.overFnt ;
		}
		else {
			menu.overFnt = overFnt;
		}
	}
	if (menu.backCol == "") {
		if (menu.parent != null) {
			menu.backCol = menu.parent.backCol;
		}
		else {
			menu.backCol = backCol;
		}
	}
	if (menu.overCol == "") {
		if (menu.parent != null) {
			menu.overCol = menu.parent.overCol;
		}
		else {
			menu.overCol = overCol;
		}
	}
	if (menu.borCol == "") {
		if (menu.parent != null) {
			menu.borCol = menu.parent.borCol;
		}
		else {
			menu.borCol = borCol;
		}
	}
	if (menu.separatorCol == "") {
		if (menu.parent != null) {
			menu.separatorCol = menu.parent.separatorCol;
		}
		else {
			menu.separatorCol = separatorCol;
		}
	}

}

function Menu (index)
{
	this.index = index;
	this.height = (parseInt(borWid) * 2);
	this.srcElement = null;
	this.itemCount = 0;
	this.subMenus = new Array (0);
	this.position = "";
	this.hasChildren = 0;
	this.parent = null;
	this.ID = IDs++;
	this.active = false;
	this.popup = getPopup (this.ID);
	this.isChild = true;
	this.tableIdMarker = "Cas_Table_Id"

	this.startHTML = null;
	this.innerHTML = "";
	this.endHTML = '</table>';

	this.popupLeft = -1;
	this.popupRight = -1;
	this.popupTop = -1;
	this.popupBottom = -1;
	
	this.origBodyWidth = -1;

	// Colours	
	this.fntCol = null;
	this.overFnt = null;
	this.backCol = null;
	this.overCol = null;
	this.borCol = null;
	this.separatorCol = null;
	
}

function getPopup (idString)
{
	if (doc)
	{
		var popup = doc.createElement ("DIV");
		popup.style.display = "none";
		popup.style.position = "absolute";
		popup.id = idString;

		if (doc.body)
			doc.body.appendChild (popup);

		return popup;
	}
	return null;
}

function timeOut() {
	markActive(activeMenu, false, "none");
	activeMenu = null;
	closeTimeout = null;
}

var subMenuCloseTimeout;
function subMenuTimeout() {
	if (activeMenu != mousePointerMenu) {
		markActive(activeMenu, false, "none");
		setActiveMenu(mousePointerMenu);
	}
	subMenuCloseTimeout = null;
}

function clearSubMenuClose() {
	if (subMenuCloseTimeout != null) {
		window.clearTimeout(subMenuCloseTimeout);
		subMenuCloseTimeout = null;
	}
}

function startSubMenuClose() {
	if (subMenuCloseTimeout == null) {
		subMenuCloseTimeout = window.setTimeout(subMenuTimeout, secondsVisible * 1000);
	}
}

var closeTimeout = null;
function mouseExitTrigger(theEvent) {
	if (closeTimeout == null) {
		closeTimeout = window.setTimeout(timeOut, secondsVisible * 1000);
	}
}

function mouseEnterTrigger(theEvent) {
	if (closeTimeout != null) {
		window.clearTimeout(closeTimeout);
		closeTimeout = null;
	}
	
	if (theEvent == null) {
		return;
	}
	var xParent = getSrcElement(theEvent);
	var menuId;
	while (xParent.tagName.toLowerCase() != "table") {
		xParent = xParent.parentNode;
	}
	
	menuId = xParent.id.substring(rootMenu.tableIdMarker.length);
	var menu = getMenuById(menuId, rootMenu);
	if (mousePointerMenu != menu) {
		setActiveMenu(menu);
		mousePointerMenu = menu;
	}
}

function setActiveRow(rowType, rowId) {
	var changed = false;

	if (rowId != activeRowId) {
		changed = true;
	}
	activeRowId = rowId;

	if (changed) {
		if (rowType == "nosubmenu") {
			startSubMenuClose();
		}
	}
}

function getDivHTML (idString, menu)
{
	var	html  = '<table border="0" cellspacing="0" cellpadding="' + itemPad + '" width=' + menuWidth;
		html += '   style="BORDER: ' + menu.borCol + ' ' + borWid + 'px ' + borSty + '; "';
		html += ' onmouseout="' + framesPrefix + 'mouseExitTrigger(event);" '
		html += ' onmouseover="' + framesPrefix + 'mouseEnterTrigger(event);" '
		html += ' id="' + idString + '" ';
		html += '	bgcolor=' + menu.backCol + ' unselectable="on">';
	return html;
}

function addMenuItem (menu, newCaption, newImage, newOnClick, newChild, isLast)
{
	var mouseOver = ' onmouseover="' + framesPrefix + 'mouseEnterTrigger(event);" ';
	var realFontSize;

	var html  = ' <tr onClick ="' + newOnClick + '" unselectable="on" ';
	if (newChild != null) {
		html += ' onMouseOver = "' + framesPrefix + 'showCascadeMenu (' + newChild.ID + ', event); ';
		html += framesPrefix + 'mouseEnterTrigger(event); ';
		html += framesPrefix + 'setActiveRow(\'submenu\', ' + (rowIDs++) + ');" ';
	}
	else {
		html += ' onMouseOver = "' + framesPrefix + 'setActiveRow(\'nosubmenu\', ' + (rowIDs++) + ');" ';
	}
	html += ' >';

	realFontSize = getFontSizeString(fntSiz);

	html += '  <td style="cursor:default; color:' + menu.fntCol + '; font: ' + realFontSize + ' ' + fntFam + '; ';
	html += '       FONT-WEIGHT:' + (fntBold ? "bold" : "normal") + '; FONT-STYLE:' + (fntItal ? "italic" : "normal") + '; '; 
	html += '       BACKGROUND-COLOR: ' + menu.backCol + '; ';

	if (!isLast) {
		html += 'BORDER-BOTTOM: ' + menu.separatorCol + ' ' + separator + 'px solid; ';
	}
	html += '" ';
	html += '     onMouseOver="this.style.backgroundColor=' + "'" + menu.overCol + "'; ";
	html += '                  this.style.color=' + "'" + menu.overFnt + "'; " + framesPrefix + 'mouseEnterTrigger(event); " ';

	var mouseOut = "";
	mouseOut += 'this.style.backgroundColor=' + "'" + menu.backCol + "'; ";
	mouseOut += 'this.style.color=' + "'" + menu.fntCol + "';";

	html += '      onMouseOut="' + mouseOut + '">';
	html += '    <NOWRAP><SPAN style="WIDTH:' + (menuWidth - 12 - (borWid * 2) - ((newChild != null) ? imgSiz : 0)) + 'px" ';
	html += mouseOver;
	html += '>' + newCaption;
	if (newChild != null) {
		html += '</SPAN><SPAN align=right><IMG src="' + imgSrc + '" height=' + imgSiz + ' width=' + imgSiz + ' ';
	html += mouseOver;
		html += ' >';
	}
	html += '    </SPAN></NOWRAP></td></tr>';

	menu.innerHTML += html;
	menu.height += parseInt(fntSiz) * 2 + (isLast ? 0 : parseInt(separator)) + (parseInt (itemPad));
	menu.itemCount++;

	if (isLast) {
		menu.popup.innerHTML = menu.startHTML + menu.innerHTML + menu.endHTML;
	}
}

function getFontSizeString (fontString) {
	var i;
	var retString;
	var relFonts = new Array();
	var isNumeric

	relFonts[1] = "xx-small";
	relFonts[2] = "x-small";
	relFonts[3] = "small";
	relFonts[4] = "medium";
	relFonts[5] = "large";
	relFonts[6] = "x-large";
	relFonts[7] = "xx-large";

	if ((fontString == null)||(fontString == "")) {
		return ("medium");
	}

	if (fontString.length == 1) {
		var n = parseInt(fontString, 10);
		if (isNaN(n)||(n < 1)||(n > 7)) {
			return ("medium");
		}
		return(relFonts[n]);
	}

	return(fontString);
}

function popUp (caption, theEvent)
{
	var index = parseInt (caption);
	for (i = 0; i < caption.length && isNaN(index);)
	{
		caption = caption.substring (1);
		index = parseInt (caption);
	}

	if (rootMenu == null) {
		rebuildMenus();
	}
	
	if (rootMenu.subMenus[index - 1]) {
		showCascadeMenu(rootMenu.subMenus[index - 1].ID, theEvent);
	}
	mouseEnterTrigger(null);
}

function showCascadeMenu (menuId, theEvent) {
	var menu = getMenuById(menuId);
	var testVar;

	try {
		testVar = menu;
		testVar = menu.popup;
		testVar = menu.popup.style;
	}
	catch (e) {
		rebuildMenus();
		menu = getMenuById(menuId);
	}

	clearSubMenuClose();

	setActiveMenu(menu);

	if (menu == null) {
		return;
	}
	if (menu.popupLeft == -1) {
		setPosition(menu, theEvent);
	}
	
	if ((doc.body.clientWidth && doc.body.clientWidth != menu.origBodyWidth)||
		(self.innerWidth && self.innerWidth != menu.origBodyWidth)) {
		setPosition(menu, theEvent);
	}
	
	menu.popup.style.display = "block";
}

function rebuildMenus() {
	activeMenu = null;
	if (closeTimeout != null) {
		window.clearTimeout(closeTimeout);
	}
	IDs = 0;
	setup();

}

function setPosition (menu, theEvent) {
	var srcElement = getSrcElement(theEvent);
	var position;
	position = getOrientation(menu.isChild, srcElement);

	if (doc.body.clientWidth) {
		menu.origBodyWidth = doc.body.clientWidth;
	}
	else if (self.innerWidth) {
		menu.origBodyWidth = self.innerWidth;
	}

	if (position == "below")
	{
		xPos = totalOffsetLeft(srcElement); 
		if (isFrames && !(menu.isChild)) {
			yPos = 0;
		}
		else {
			yPos = srcElement.offsetHeight + totalOffsetTop (srcElement);
		}
	}
	else {
		var xParent = srcElement;
		var width_xParent;
		while (xParent && xParent.tagName.toUpperCase() != "TABLE") {
			xParent = xParent.offsetParent;
		}
		
		width_xParent = parseInt(xParent.width, 10);
		if (isNaN(width_xParent)) {
			width_xParent = parseInt(xParent.offsetWidth, 10)
		}

		xPos = (isFrames && !(menu.isChild)) ? 0 : (width_xParent + totalOffsetLeft(xParent));
		if (position == "left") {
			if (doc.body.clientWidth) {
				xPos = doc.body.clientWidth - menuWidth;
			}
			else if (self.innerWidth) {
				xPos = self.clientWidth - menuWidth;
			}
		}

		yPos = totalOffsetTop (srcElement);
		var i=0;
	}

	if (isFrames)
	{
		var parentFrame = null;

		if (srcElement.document) {
			if (srcElement.document.parentWindow) {
				parentFrame = srcElement.document.parentWindow.frameElement;
			}
		}	

		if (bodyFrame.window.frameElement)
		{
			if (position == "below")
				xPos -= totalOffsetLeft (bodyFrame.window.frameElement);
			else
				yPos -= totalOffsetTop (bodyFrame.window.frameElement);
		}
		if (parentFrame)
		{
			if (position == "below")
				xPos += totalOffsetLeft (parentFrame);
			else
				yPos += totalOffsetTop (parentFrame);			
		}

		if (xPos < 0)
			xPos = 0;
		if (yPos < 0)
			yPos = 0;

		if (!(menu.isChild))
		{
			xPos += doc.body.scrollLeft;
			yPos += doc.body.scrollTop;
		}

	}

	setAbsolutePosition(menu, menu.isChild, position, xPos, yPos, theEvent);
}

function getOrientation (isChildMenu, srcElement)
{
	var position = "";
	if (isChildMenu)
		position = "right";
	else
	{
		if (isFrames)
		{
			switch (navFrLoc)
			{
				case "customtop":
					position = "below";
					break;
				case "customleft":
					position = "right";
					break;
				case "customright":
					position = "left";
					break;

				case "left":
					position = "right";
					break;
				case "right":
					position = "left";
					break;
				case "top":
					position = "below";
					break;
					
				default:
					position = "below";
			}
		}
		else
		{
			var parentRow = srcElement;

			while (parentRow && parentRow.tagName && parentRow.tagName.toUpperCase() != "TR") {
				parentRow = parentRow.parentNode;
			}

			if (parentRow)
			{
				if (parentRow.cells && parentRow.cells.length > 1)
					position = "below";
				else
				{
					var parentTable = parentRow;
					while (parentTable && parentTable.tagName.toUpperCase () != "TABLE")
						parentTable = parentTable.parentElement;
						
					if (parentTable && parentTable.rows && parentTable.rows.length > 1)
						position = "right";
					else
					{
						var xOffset = totalOffsetLeft (srcElement);
						var yOffset = totalOffsetTop (srcElement);
						position = (xOffset > yOffset) ? "below" : "right";
					}
				}
			}
		}
	}
	return position;
}

function setAbsolutePosition (menu, isChildMenu, position, xPos, yPos, theEvent)
{
	if (!isChildMenu)
		if (activeMenu && activeMenu.popup && activeMenu.popup.style.display == "block")
			activeMenu.popup.style.display = "none";

	if (activeSubMenu && activeSubMenu.popup && activeSubMenu.popup.style.display == "block")
		activeSubMenu.popup.style.display = "none";	
	activeSubMenu = null;

	var overlap;
	if (perCentOver || perCentOver == 0)
		overlap = perCentOver / 100 * menuWidth;
	else
		overlap = childOverlap;

	var posLeft = xPos - (isChildMenu ? overlap : 0);
	var posRight = xPos + menuWidth - (isChildMenu ? overlap : 0);
	var posTop = yPos + (isChildMenu ? childOffset - borWid : 0);
	var posBottom = yPos + menu.height - (isChildMenu ? borWid : 0);

	var bodyClientWidth;
	if (doc.body.clientWidth) {
		bodyClientWidth = doc.body.clientWidth;
	}
	else if (self.innerWidth) {
		bodyClientWidth = self.clientWidth;
	}

	if (position != "left" && (bodyClientWidth + doc.body.scrollLeft) < posRight)
	{
		
		if (isChildMenu)
		{
			if (posLeft >= (menuWidth * 2))
			{
				posLeft -= ((menuWidth * 2) - (overlap)); 
				posRight = posLeft + menuWidth;
				position = "left";
			}
		}
		else {
			if ((bodyClientWidth + doc.body.scrollLeft) > menuWidth)
			{
				posRight = (bodyClientWidth + doc.body.scrollLeft);
				posLeft = posRight - menuWidth;
				position = "absright";
			}				
		}
	}
	
	
	if (menu.popup == null || menu.popup.parentNode == null)
	{
		var newPopup = getPopup ();
		newPopup.innerHTML = menu.startHTML + menu.innerHTML + menu.endHTML;
		
		menu.popup = newPopup;
	}

	menu.popup.style.left = posLeft + "px";
	menu.popup.style.right = posRight + "px";
	menu.popup.style.top = posTop + "px";
	menu.popup.style.bottom = posBottom + "px";
	menu.popup.style.display = "block";

	menu.popupLeft = posLeft;
	menu.popupRight = posRight;
	menu.popupTop = posTop;
	menu.popupBottom = posBottom;
}

function popDown (triggeredByCaption, theEvent)
{
	mouseExitTrigger(null);
}

function setActiveMenu (menu) {
	if (menu == activeMenu) {
		return;
	}
	markActive(activeMenu, false, "none");
	activeMenu = menu;
	markActive(menu, true, "block");
}

function markActive(menu, val, disp) {
	if (menu == null) {
		return;
	}
	menu.active = val;
	menu.popup.style.display = disp;
	if (menu.parent != null) {
		markActive(menu.parent, val, disp);
	}
}

function totalOffsetLeft (object)
{
	if ((object)&&(object.offsetLeft != null))
	{
		var offset = object.offsetLeft;
		if (object.offsetParent)
			offset += totalOffsetLeft (object.offsetParent);
		else
			offset += totalOffsetLeft (object.parentElement);
		return offset;
	}
	return 0;
}

function totalOffsetTop (object)
{
	if ((object)&&(object.offsetTop != null))
	{
		var offset = object.offsetTop;
		if (object.offsetParent)
			offset += totalOffsetTop (object.offsetParent);
		else
			offset += totalOffsetTop (object.parentElement);
		return offset;
	}
	return 0;
}

function getEvent ()
{
	if (window.event) {
		return window.event;
	}
	if (parent.frames.BODY && parent.frames.BODY.event) {
		return parent.frames.BODY.event;
	}
	if (parent.frames.NAV && parent.frames.NAV.event) {
		return parent.frames.NAV.event;
	}
	if (parent.frames.SUBNAV && parent.frames.SUBNAV.event) {
		return parent.frames.SUBNAV.event;
	}
	return null;
}

function getSrcElement(theEvent) {
	var fallbackEvent;
	if (theEvent == null) {
		fallbackEvent = getEvent();
		if (fallbackEvent == null) {
			return null;
		}
		else {
			return getSrcElement(fallbackEvent);
		}
	}
	if (theEvent.srcElement) {
		return(theEvent.srcElement);
	}
	else if (theEvent.target) {
		return(theEvent.target);
	}
	else {
		return (null);
	}
}

function getMenuById(id, searchNode) {
	var i;
	var res;
	if (searchNode == null) {
		searchNode = rootMenu;
	}
	for (i=0; i < searchNode.subMenus.length; i++) {
		if (searchNode.subMenus[i].ID == id) {
			return(searchNode.subMenus[i]);
		}
		if (searchNode.subMenus[i].hasChildren) {
			res = getMenuById(id, searchNode.subMenus[i]);
			if (res != null) {
				return(res);
			}
		}
	}
	return(null);
}

