<!-- Published: 7/19/2004 13:15 -->
function VTgenerateMenu(menu) {
var html, menuHeight=0;

	for (var i=0; i < menu.items.length; i++)	{
		var border = "";
		var thisItem = menu.items[i];
		var newDiv = null;		
		var maxk = 22;
		var s = thisItem.label;
		if(s.length>maxk && s.indexOf("<br />")){
			var a = s.split(" ");
			if(a.length>1){			
				for(k=a.length-1; k>0; k--){		
					var s2="";
					var l=0;
					for(j=0; j<a.length; j++){
						s2=s2+a[j];
						if(j<a.length-1){
							if(j==k-1){
								l=s2.length;								
								s2+="<br />";
							}
							else
								s2+=" ";
						}
					}
					if(l<=maxk) break;
				}
				thisItem.label = s2;
			}
		}
		
		html = VTgenerateTable(thisItem);
		newDiv = document.createElement("div");
		newDiv.className = "menu";
		newDiv.innerHTML = html;
		thisItem.div = menu.root.container.div.appendChild(newDiv);
		if (thisItem.subMenu) {
			thisItem.submenuImg = document.getElementById(menu.root.prefix+"ISub"+thisItem.ID);
			thisItem.submenuImg.src = thisItem.menu.subClosedImg.src;
		}
		thisItem.activate = function () {
			this.HTMLObj.className = this.menu.activeClass;
			this.HTMLObj.style.backgroundColor = "#CEEBFF";
		};
		thisItem.unactivate = function () {
			this.HTMLObj.className = this.menu.normalClass;
			this.HTMLObj.style.backgroundColor = "#FFFFFF";
			if (this.subMenu) {this.submenuImg.src = this.menu.subLitClosedImg.src;}
		};
		thisItem.dim  = VTdim;
		thisItem.light = VTlight;

		thisItem.HTMLObj = document.getElementById(menu.root.prefix+thisItem.ID);
		thisItem.height = thisItem.HTMLObj.offsetHeight;
		
		menuHeight += thisItem.height;
		thisItem.HTMLObj.className = thisItem.menu.normalClass;
		thisItem.move = moveLyr;
		thisItem.hide = hideLyr;
		thisItem.show = showLyr;
	}
	menu.height = menuHeight;
}
function VTgenerateTable(Item) {
var html;
var identwidth = Item.menu.root.leftmargin + (Item.level * Item.menu.root.identsize);
var textwidth = Item.menu.root.width - identwidth - 13;

			identborder = " style='border-bottom: #CEEBFF 1px solid;padding-left:"+identwidth+"px'";
			border = " style='border-bottom: #CEEBFF 1px solid'";
			html = "<table width='"+Item.menu.root.width+"' cellspacing='0' cellpadding='0' border='0'>";
			html += "<tr id='"+Item.menu.root.prefix+Item.ID+"' class='"+Item.menu.normalClass+"' onmouseover='VToverItem("+Item.ID+")' onmouseout='VToutItem("+Item.ID+")' onclick='VTclickItem("+Item.ID+")'>";
			html += "<td width='"+textwidth+"' "+identborder+">";
			html += Item.label;
			html += "</td>";
			html += "<td width='13' "+border+">";
			if (Item.subMenu)
				html += "<img border='0' alt='' height='17' width='13' id='"+Item.menu.root.prefix+"ISub"+Item.ID+"' src='' />";
			else
				html += "<img border='0' alt='' height='17' width='13' src='"+EmptyImg.src+"' />";
			html += "</td>";
			html += "</tr>";
			html += "</table>\n";		
	return html;
}
function VToverItem(itemID) {
var thisItem = VTlookUpTable[itemID];

	if (thisItem == VTROOT.activeItem || (thisItem.subMenu && thisItem.subMenu.isOpen)) return;
	thisItem.light();
}
function VToutItem(itemID) {
var thisItem = VTlookUpTable[itemID];

	if (thisItem == VTROOT.activeItem || (thisItem.subMenu && thisItem.subMenu.isOpen)) return;
	thisItem.dim();
}
function VTclickItem(itemID) {
	//alert(itemID);	
	setTopId(itemID);
	var thisItem = VTlookUpTable[itemID];
	
	if (thisItem == MENUS[VT].menuRoot.items[0] || (thisItem.level ==0 && !thisItem.subMenu)) {//First menu item: HOME
		reverseOpenMenus(VTROOT, "VTcloseMenu(menu)");
		showSwan();
	} else {
		//reverseOpenMenus(VTROOT, "VTcloseMenu(menu)");
		if (thisItem.subMenu) {
				
			if (thisItem.subMenu.isOpen) {
				reverseOpenMenus(thisItem.subMenu,"VTcloseMenu(menu)");
				thisItem.submenuImg.src = thisItem.menu.subLitClosedImg.src;
				thisItem.light();
			} else {
				for (var i=0; i < thisItem.menu.items.length; i++) {
					if (i != thisItem.indexInMenu) {
						if (thisItem.menu.items[i].subMenu && thisItem.menu.items[i].subMenu.isOpen) {
							reverseOpenMenus(thisItem.menu.items[i].subMenu,"VTcloseMenu(menu)");
						}
					}
				}
				thisItem.HTMLObj.className = thisItem.menu.activeClass;
				thisItem.submenuImg.src = thisItem.menu.subLitOpenImg.src;
				// Dit voor deeplinking
				var iLevel = parseInt(thisItem.level);
				if(iLevel > 0) {
					if(iLevel > 2){
						if(thisItem.subMenu.parentItem.menu.parentItem.menu.parentItem.menu.isOpen)
						VTopenMenu(thisItem.subMenu.parentItem.menu.parentItem.menu.parentItem.menu);
					}
					if(iLevel > 1) {
						alert(thisItem.subMenu.parentItem.menu.parentItem.menu.isOpen);
						if(!thisItem.subMenu.parentItem.menu.parentItem.menu.isOpen)
							VTopenMenu(thisItem.subMenu.parentItem.menu.parentItem.menu);
					}
					if(!thisItem.subMenu.parentItem.menu.isOpen)	
						VTopenMenu(thisItem.subMenu.parentItem.menu);
				}
				// einde mod voor deeplinking
				VTopenMenu(thisItem.subMenu);
				hideSwan();
			}
		}
		else {
			for (var i=0; i < thisItem.menu.items.length; i++) {
				if (i != thisItem.indexInMenu) {
					if (thisItem.menu.items[i].menu && thisItem.menu.items[i].menu.isOpen) {
						reverseOpenMenus(thisItem.menu.items[i].menu,"VTcloseMenu(menu)");
			     		}
			   	}
			}
			thisItem.HTMLObj.className = thisItem.menu.activeClass;
			//dit voor deeplinking
			var iLevel = parseInt(thisItem.level);
			if(iLevel > 1) {
				if(iLevel > 2) {
					if(!thisItem.menu.parentItem.menu.parentItem.menu.isOpen)
						VTopenMenu(thisItem.menu.parentItem.menu.parentItem.menu);
				}
				if(!thisItem.menu.parentItem.menu.isOpen)
					VTopenMenu(thisItem.menu.parentItem.menu);
			}
			// einde deeplinking
			VTopenMenu(thisItem.menu);
			hideSwan();
		}
	}
	var allClosed = true;
	for (var i=0; i < VTROOT.children.length; i++) if (VTROOT.children[i].isOpen) allClosed = false;
	if (allClosed) showSwan();
	checkForScroll();
	if (thisItem.href != "") {
		top.frames.content.location = thisItem.href;
			if (!thisItem.subMenu) {
			if (VTROOT.activeItem && (VTROOT.activeItem !=thisItem)) VTROOT.activeItem.unactivate();
			VTROOT.activeItem = thisItem;
			thisItem.activate();
		}
	}
}
function VTopenMenu(menu) {
	var iParentY = menu.parentItem.y;
	var iParentHeight = menu.parentItem.height;
	var iTotalHeight = parseInt(iParentY) + parseInt(iParentHeight);
	
	if(!isNaN(iTotalHeight)) {
		menu.items[0].move(0,iTotalHeight);
		menu.items[0].show();
		for (var i=1; i < menu.items.length; i++) {
			menu.items[i].move(0,menu.items[i-1].y + menu.items[i-1].height);
			menu.items[i].show();
		}
		VTsplitMenu(menu.parentMenu, menu.parentItem.indexInMenu+1, menu.height);
		menu.isOpen = true;
	}
	else {	
		/*
		menu.items[0].move(0,iTotalHeight);
		menu.items[0].show();
		for (var i=1; i < menu.items.length; i++) {
			menu.items[i].move(0,menu.items[i-1].y + menu.items[i-1].height);
			menu.items[i].show();
		}
		VTsplitMenu(menu.parentMenu, menu.parentItem.indexInMenu+1, menu.height);
		menu.isOpen = true;
		*/
	}	
}
function VTcloseMenu(menu) {
	if (!menu.parentItem) return;
	VTmergeMenu(menu.parentMenu, menu.parentItem.indexInMenu+1, menu.height)
	for (var i=0; i < menu.items.length; i++) {
		menu.items[i].hide();
	}
	if (menu.parentItem) {menu.parentItem.unactivate(); menu.parentItem.dim();};
	menu.isOpen = false;
}
function VTsplitMenu(menu, fromIndex, distance) {
	for (var i=fromIndex; i<menu.items.length; i++) {
		menu.items[i].move(0,menu.items[i].y + distance);
	}
	if (menu.parentMenu) VTsplitMenu(menu.parentMenu, menu.parentItem.indexInMenu+1, distance);
}
function VTmergeMenu(menu, fromIndex, distance) {
	for (var i=fromIndex; i<menu.items.length; i++) {
		menu.items[i].move(0,menu.items[i].y - distance);
	}
	if (menu.parentMenu) VTmergeMenu(menu.parentMenu, menu.parentItem.indexInMenu+1, distance);
}
function VTdim() {
	if (this == this.menu.root.activeItem) return;
	this.HTMLObj.className = this.menu.normalClass;
}
function VTlight() {
	if (this == this.menu.root.activeItem) return;
	this.HTMLObj.className = this.menu.hiliteClass;
}
//=========================SCROLLER FUNCTIONS=============================
var actualHeight = 0;
var availableHeight = 0;
var upButton = null;
var downButton = null;
var scrollFactor = 8;
function checkForScroll() {
	var metaHeight = getHeight("meta");
	
	if (determineHeight() + metaHeight > availableHeight) {
		upButton.move(0,0);
		downButton.move(0, availableHeight - (metaHeight));
		upButton.show();
		downButton.show();
		MENUS[VT].container.move(0, upButton.height - 1);
	} else {
		upButton.hide();
		downButton.hide();
		MENUS[VT].container.move(0, 0);
	}
}
function determineHeight() {
	if (browser.substr(0,2)=="IE") availableHeight = document.body.clientHeight; else availableHeight = window.innerHeight;
	actualHeight = 0;
	traverseOpenMenus(MENUS[VT].menuRoot, "sumHeight(menu.items)");
	return actualHeight;
}
function sumHeight(items) {
	for (var i=0; i < items.length; i++) {
		actualHeight += items[i].height;
	}
}
var unique = 1;
function ScrollButton(imageSrc, overImageSrc) {
var html;

	this.imageID = unique++;
	html = "<table width='155' cellspacing='0' cellpadding='0' border='0'>";
	html += "<tr><td height='19'><img border='0' id='button"+this.imageID+"' style=cursor:default; width='155' height='19' src='"+imageSrc+"'></td></tr>";
	html += "</table>\n";

	var newDiv = document.createElement("div");
	newDiv.className = "menu";
	newDiv.innerHTML = html;
	this.div = document.body.appendChild(newDiv);
	this.buttonImage = document.getElementById("button"+this.imageID);
	this.div.style.zIndex = 200;
	this.height= 19;
	this.image = new Image();
	this.image.src = imageSrc;
	this.overImage = new Image();
	this.overImage.src = overImageSrc;
	this.move = moveLyr;
	this.hide = hideLyr;
	this.show = showLyr;
	return this;
}
ScrollButton.prototype.dim = function () {this.buttonImage.src = this.image.src;};
ScrollButton.prototype.light = function () {this.buttonImage.src = this.overImage.src;};
function createScrollButtons() {
	determineHeight();
	if (browser.substring(0,2) == "NS" || browser.substring(0,3) == "IE4") {
			scrollFactor = 10;
	} else {
			if (browser == "IE5MAC" || browser == "IE4MAC") {
					scrollFactor = 18;
			} else {
					scrollFactor = 2;
			}
	}
	
	MENUS[VT].container.moveUp  = function x(amount){this.div.style.top = parseInt(this.div.style.top) - amount;};
	MENUS[VT].container.moveDown = function x(amount){this.div.style.top = parseInt(this.div.style.top) + amount;};
	upButton = new ScrollButton("/generic/static_img/icons/scroll_up.gif","/generic/static_img/icons/scroll_up_hi.gif");
	downButton = new ScrollButton("/generic/static_img/icons/scroll_down.gif","/generic/static_img/icons/scroll_down_hi.gif");
	upButton.move(0,0);
	downButton.move(0, availableHeight - 19);
	upButton.div.onmouseover = function (e) {upButton.light(); startScrollerDown();};
	upButton.div.onmouseout = function (e) {upButton.dim(); stopScroller();};
	downButton.div.onmouseover = function (e) {downButton.light(); startScrollerUp();};
	downButton.div.onmouseout = function (e) {downButton.dim(); stopScroller();};
}
var functionPointer = "false";
function startScrollerUp() {functionPointer = "scrollMenuUp()";scroll();}
function startScrollerDown() {functionPointer = "scrollMenuDown()";scroll();}
function stopScroller() {functionPointer = "false";}
function scroll() {
  if (eval(functionPointer)) {
    setTimeout("scroll()", 2);
  } else {
    functionPointer = "false";
  }
}
function scrollMenuUp() {
  var metaHeight = getHeight("meta");
  var actualY = parseInt(MENUS[VT].container.div.style.top);
  if (actualY + metaHeight > availableHeight - actualHeight - 19 + 1 + scrollFactor) {
    MENUS[VT].container.moveUp(scrollFactor);
    return true;
  } else {
    //MENUS[VT].container.move(0, availableHeight - actualHeight - downButton.height + 1);
    return false;
  }
}
function scrollMenuDown() {
var actualY = parseInt(MENUS[VT].container.div.style.top);
  if (actualY < upButton.height - 1 - scrollFactor) {
    MENUS[VT].container.moveDown(scrollFactor);
    return true
  } else {
    MENUS[VT].container.move(0, upButton.height - 1);
    return false;
  }
}
function getTopId() {
var iId = parent.frames[0].itemId;
  return iId;
}
function setTopId(id) {
  //debug("topid = " + id); 
  parent.frames[0].itemId = id;
}
function getHeight(id) {
	var oObj=document.getElementById(id);
	return oObj.offsetHeight;
}
function debug(str) {
	//parent.frames[0].debug.innerHTML = str;
}


