var dom = document.getElementById ? true:false;
var nn4 = document.layers ? true:false;
var ie4 = document.all ? true:false;

loaded = false;
menuVLoaded = false;
	
// mouse coordinates
xMin_V = 0;
xMax_V = 0;
yMin_V = 0;
yMax_V = 0;

scrollPosV = 0; // IE: handling scrollbar
currentMenuV = 0; // selected menu
menuVLRef = ""; // NN4: refer to image i layer

// Fix NS4 resize bug
function reDo() {
	if (innerWidth != origWidthV || innerHeight != origHeightV) {
		location.reload();
	}
}
if (nn4) {
	var origWidthV = innerWidth;
	var origHeightV = innerHeight;
	onResize = reDo;
}

// init layer-objects
function initV() {
	if (nn4) {
		menuVL = document.menubarV;
		menuCV = document.menucontentV;
		menuVLRef = "menubarV.document.";
		document.captureEvents(Event.MOUSEMOVE)
	} else	if (ie4) {
		menuVL = document.all.menubarV.style;
		menuCV = document.all.menucontentV.style;
		cursorV = "hand";
	} else if (dom) {
		menuVL = document.getElementById("menubarV").style;
		menuCV = document.getElementById("menucontentV").style;
		cursorV = "pointer";
	}
}

function initMenuV(dest) {
	//alert(menuV.length);
	hauteur = (menuV.length-1) * 45;
	HTML_V = '<table width="130" height="'+ hauteur + '" cellpadding="0" cellspacing="0" border="0" bgcolor="#3399FF">';

	for (t=0; t<menuV.length-1; t++) {
		if (t != menuPageV)
// nedenstående linie er ændret
		{
//			alert('menuPage=' + menuPageV);
			HTML_V += '<tr><td align="center"><img src="/sitedesign/standard/images/dot_trans.gif" width="16" height="20" id="m_V' + t + '_1" name="m_V' + t + '_1"></td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td valign="middle"><a href="javascript:location.href=\''+ menuV[t][1] + '\';" class="TopmenuDHTML" onMouseover="over(' + t + ');window.status=\''+ menuV[t][0] +'\';return true;">' + menuV[t][0] + '</a></td></tr><tr><td><img src="/sitedesign/standard/images/g_menu_motif.gif"></td></tr></table></td><td><img src="/sitedesign/standard/images/dot_trans.gif" width="1" height="20" id="m_V' + t + '_2" name="m_V' + t + '_2"></td></tr>';
		}
		else
		{
				HTML_V += '<tr><td><a href="javascript:location.href=\''+ menuV[t][1] + '\';" class="TopmenuDHTML" onMouseover="over(' + t + ');" >' + menuV[t][0] + '</a></td></tr>';
//				HTML_V += '<tr><td class="TopmenuDHTML" ><a href="javascript:location.href=\''+ menuV[t][1] + '\';" class="TopmenuDHTML" onMouseover="over(' + t + ');window.status=\'' + menuV[t][0] + '\';return true;" >' + menuV[t][0] + '</a></td></tr>';
		}	
	}
	HTML_V += '</table>';
//			
	HTML_V += '<br><table bgcolor="#FFCC66" width="130" height="30" cellpadding="0" cellspacing="0" border="0">';
	for (t=menuV.length-1; t<menuV.length; t++) {
		if (t != menuPageV)
// nedenstående linie er ændret
		{
			HTML_V += '<tr><td align="center"><img src="/sitedesign/standard/images/dot_trans.gif" width="16" height="20" id="m_V' + t + '_1" name="m_V' + t + '_1"></td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="middle"><a href="javascript:location.href=\''+ menuV[t][1] + '\';" class="Topmenu2DHTML" onMouseover="over2(' + t + ');window.status=\''+ menuV[t][0] +'\';return true;">' + menuV[t][0] + '</a></td></tr><tr><td width="112"><img src="/sitedesign/standard/images/dot_trans.gif"></td></tr></table></td><td><img src="/sitedesign/standard/images/dot_trans.gif" width="1" height="20" id="m_V' + t + '_2" name="m_V' + t + '_2"></td></tr>';
		}
		else
		{
			HTML_V += '<tr><td><a href="javascript:;" class="Topmenu2DHTML" onMouseover="over2(' + t + ');">' + menuV[t][0] + '</a></td></tr>';
		}	
	}
	HTML_V += '</table><br><img src="/sitedesign/standard/images/dot_trans.gif" width="1" height="1">';
	
	if (nn4) {
		document.menubarV.document.open();
		document.menubarV.document.write(HTML_V);
		document.menubarV.document.close();
	} else	if (ie4) {
		menubarV.innerHTML = HTML_V;
	} else if (dom) {
		document.getElementById("menubarV").innerHTML = HTML_V;
	}
	menuVL.top = ysPosV('posGifV')-30;
	menuVL.left = xsPosV('posGifV');
	menuVL.visibility = "visible";
	menuVLoaded = true;
}

function ysPosV(what){
	if(ie4)
		return yIEV(eval('document.'+what));
	else if(nn4)
		return eval('document.'+what+'.y_V');
	else if(dom)
		return yIEV(document.getElementById(what));
}

function xsPosV(what){
	if(ie4)
		return xIEV(eval('document.'+what));
	else if(nn4)
		return eval('document.'+what+'.x_V');
	else if(dom)
		return xIEV(document.getElementById(what));
}

function yIEV(what){
	if(what.offsetParent)
		return parseInt(what.offsetTop + yIEV(what.offsetParent));
	else
		return parseInt(what.offsetTop);
}


function xIEV(what){
	if(what.offsetParent)
		return parseInt(what.offsetLeft + xIEV(what.offsetParent));
	else
		return parseInt(what.offsetLeft);
}

function xsHeightV(what) {
	if(ie4)
		return(parseInt(eval('document.all.' + what + '.scrollHeight')));
	else if(nn4)
		return(eval('document.' + what + '.clip.bottom'));
	else if(dom)
		return(parseInt(eval('document.getElementById("' + what + '").offsetHeight')));
}

function xsWidthV(what) {
	if(ie4)
		return(parseInt(eval('document.all.' + what + '.scrollWidth')));
	else if(nn4)
		return(eval('document.' + what + '.clip.right'));
	else if(dom)
		return(parseInt(eval('document.getElementById("' + what + '").offsetWidth')));
}

var menuTimer = null;

mouse_Y_V = 0;
mouse_X_V = 0;

// capture mouvement de la souris
function move(e) {
	if(ie4){
		mouse_Y_V = event.clientY;
		mouse_X_V = event.clientX;
	}
	else if(nn4 || dom){
		mouse_Y_V = e.pageY;
		mouse_X_V = e.pageX;
	}	

	if((mouse_X_V < xMin_V || mouse_X_V-135 > xMax_V || mouse_Y_V < yMin_V || mouse_Y_V > yMax_V+20) && currentMenuV >=0 && menuVLoaded) {
		menuTimer = setTimeout('hideMenuV()',500);
	} else {
		clearTimeout(menuTimer);
	}
}

document.onmousemove = move;

function hideMenuV() {
	if ((mouse_X_V < xMin_V || mouse_X_V-135 > xMax_V || mouse_Y_V < yMin_V || mouse_Y_V > yMax_V+20) && currentMenuV >=0 && menuVLoaded) {
		menuCV.visibility = "hidden";
		currentMenuV = 0;
	}
}

if (ie4 || dom) {
	window.onresize = posMenuNav;
}

function posMenuNav() {
	menuVL.left = xsPosV('posGifV');
}

function makemenuVcontent(what) {
//	width = xsPosV(menuVLRef+'m_V'+what+'_2') - xsPosV(menuVLRef+'m_V'+what+'_1')-11;

//	HTML = '<table cellpadding="0" cellspacing="0" border="0"><tr><td><font color="#000000">' + menu[what][0] + '</font></td></tr></table><img src="/sitedesign/standard/images/dot_trans.gif" width="1" height="4"><br>';
//	HTML_V = '<table cellpadding="0" cellspacing="0" border="0"><tr><td><img src="/sitedesign/standard/images/dot_trans.gif" width="11" height="45"></td><td class="TopmenuDHTML"><font color="#FFFFFF">' + menuV[what][0] + '</font></td></tr></table><img src="/sitedesign/standard/images/dot_trans.gif" width="1" height="4"><br>';
	HTML_V = '';
	// FOND DE MENU
	if (menuV[what][2])
	{
	HTML_V += '<table cellpadding="1" cellspacing="1" border="0"><tr><td bgcolor="#3399FF"><table cellpadding="3" cellspacing="0" border="0" bgcolor="#CCE6FF">';
	for (t=2; t<=menuV[what].length-1; t=t+2) {
		if ((t+1)/2 == localPage && what == menuPageV) {
				HTML_V += '<tr><td class="menuSub" bgcolor="#C5CCD2"><img src="/sitedesign/standard/images/dot_trans.gif" width="7" height="1"><font color="#B6E005">' +  menuV[what][t] + '</font>&nbsp;&nbsp;</a>';
		} else {
			if (nn4)
				HTML_V += '<tr><td><img src="/sitedesign/standard/images/dot_trans.gif" width="7" height="1"><a href="' + menuV[what][t+1] + '" class="menuSub">' +  menuV[what][t] + '&nbsp;&nbsp;</a>';
			else
				HTML_V += '<tr><td class="menuSub" style="cursor:' + cursorV + '" id="sub_V' + t + '" name="sub_V' + t + '" onMouseover="subOver(' + t + ');window.status=\''+ menuV[what][t] +'\';return true;" onMouseout="subOut(' + t + ')" onClick="location.href=\''+ menuV[what][t+1] + '\';"><img src="/sitedesign/standard/images/dot_trans.gif" width="7" height="1">' + menuV[what][t] + '&nbsp;&nbsp;</td></tr>';
		}
	}
	HTML_V += '</table></td></tr></table><br>';
	}
	x_V = xsPosV(menuVLRef+'m_V'+what+'_1');
	y_V = ysPosV(menuVLRef+'m_V'+what+'_1');
//	alert("x_V =" + x_V);
//	alert("y_V =" + y_V);
	
	if (nn4) {
		document.menucontentV.document.open();
		document.menucontentV.document.write(HTML_V);
		document.menucontentV.document.close();
		x_V += xsPosV('posGifV');
		y_V += ysPosV('posGifV');
	} else 	if (ie4) {
		menucontentV.innerHTML = HTML_V;
	} else if (dom) {
		document.getElementById("menucontentV").innerHTML = HTML_V;
	}

	menuCV.left = x_V + 134;
	menuCV.top = y_V - 10;
	menuCV.visibility = "visible";
	
//	render(menuCV.left);
//	render(menuCV.top);
	// mouse-over area for menus
	if (ie4 || dom) {
		scrollPosV = document.body.scrollTopV;
	}
	xMin_V = x_V;
	xMax_V = x_V + xsWidthV('menucontentV');
	yMin_V = y_V - scrollPosV;
	yMax_V = y_V + xsHeightV('menucontentV')-scrollPosV;
	
	currentMenuV = what;
}

function makemenuVcontent2(what) {
//	width = xsPosV(menuVLRef+'m_V'+what+'_2') - xsPosV(menuVLRef+'m_V'+what+'_1')-11;

	HTML_V = '';
	// FOND DE MENU
	if (menuV[what][2])
	{
	HTML_V += '<br><table cellpadding="1" cellspacing="1" border="0" bgcolor="#FFCC33"><tr><td bgcolor="#F9E5AA"><table cellpadding="3" cellspacing="0" border="0">';
	for (t=2; t<=menuV[what].length-1; t=t+2) {
		if ((t+1)/2 == localPage && what == menuPageV) {
				HTML_V += '<tr><td class="menuSub2" bgcolor="#cdcdcd"><img src="/sitedesign/standard/images/dot_trans.gif" width="7" height="1"><font color="#3399FF">' +  menuV[what][t] + '</font>&nbsp;&nbsp;</a>';
		} else {
			if (nn4)
				HTML_V += '<tr><td><img src="/sitedesign/standard/images/dot_trans.gif" width="7" height="1"><a href="' + menuV[what][t+1] + '" class="menuSub2">' +  menuV[what][t] + '&nbsp;&nbsp;</a>';
			else
				HTML_V += '<tr><td class="menuSub2" style="cursor:' + cursorV + '" id="sub_V' + t + '" name="sub_V' + t + '" onMouseover="subOver2(' + t + ');window.status=\''+ menuV[what][t] +'\';return true;" onMouseout="subOut2(' + t + ')" onClick="location.href=\''+ menuV[what][t+1] + '\'"><img src="/sitedesign/standard/images/dot_trans.gif" width="7" height="1">' + menuV[what][t] + '&nbsp;&nbsp;</td></tr>';
		}
	}
	HTML_V += '</table></td></tr></table><br>';
	}
	x_V = xsPosV(menuVLRef+'m_V'+what+'_1');
	y_V = ysPosV(menuVLRef+'m_V'+what+'_1');

	if (nn4) {
		document.menucontentV.document.open();
		document.menucontentV.document.write(HTML_V);
		document.menucontentV.document.close();
		x_V += xsPosV('posGifV');
		y_V += ysPosV('posGifV');
	} else 	if (ie4) {
		menucontentV.innerHTML = HTML_V;
	} else if (dom) {
		document.getElementById("menucontentV").innerHTML = HTML_V;
	}

	menuCV.left = x_V + 134;
	menuCV.top = y_V - 10;
	menuCV.visibility = "visible";
	// mouse-over area for menus
	if (ie4) {
		scrollPosV = document.body.scrollTopV;
	}
	xMin_V = x_V;
	xMax_V = x_V + xsWidthV('menucontentV');
	yMin_V = y_V - scrollPosV
	yMax_V = y_V + xsHeightV('menucontentV')-scrollPosV;
	
	currentMenuV = what;
}
	

function subOver(what) {
	if (ie4) {
		bg1V = eval('sub_V' + what);
	} else {
		bg1V = document.getElementById('sub_V' + what);	
	}
	bg1V.style.backgroundColor = "#F5FAFF";
	bg1V.style.color = "#3366CC";
	bg1V.style.fontWeight = "normal";
}

function subOver2(what) {
	if (ie4) {
		bg1V = eval('sub_V' + what);
	} else {
		bg1V = document.getElementById('sub_V' + what);	
	}
	bg1V.style.backgroundColor = "#FBF4DF";
	bg1V.style.color = "#3366CC";
	bg1V.style.fontWeight = "normal";
}

function subOut(what) {
	if (ie4) {
		bg1V = eval('sub_V' + what);
	} else {
		bg1V = document.getElementById('sub_V' + what);	
	}
	bg1V.style.backgroundColor = "#CCE6FF";
	bg1V.style.color = "#3399FF";
	bg1V.style.fontWeight = "normal";
}

function subOut2(what) {
	if (ie4) {
		bg1V = eval('sub_V' + what);
	} else {
		bg1V = document.getElementById('sub_V' + what);	
	}
	bg1V.style.backgroundColor = "#F9E5AA";
	bg1V.style.color = "#6699CC";
	bg1V.style.fontWeight = "normal";
}

function over(what) {
	if (currentMenuV > 0) {
		menuCV.visibility = "hidden";
	}
	currentMenuV = what;
	makemenuVcontent(what);
}

function over2(what) {
	if (currentMenuV > 0) {
		menuCV.visibility = "hidden";
	}
	currentMenuV = what;
	makemenuVcontent2(what);
}

function out(what) {
	menuCV.visibility = "hidden";
	currentMenuV = 0;
}
