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
standard = "serge_lagauche"
//alert ( standard );

// 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) {
	hauteur = menuV.length * 22;
	HTML_V = '<table width=145 height="'+ hauteur + '" cellpadding="0" cellspacing="0" border="0">';

	for (t=0; t<menuV.length; t++) {
		if (t != menuPageV)
		{
				HTML_V += '<tr bgcolor="#CDB89A"><td valign="top"><img src="/sitedesign/'+standard+'/images/dot_trans.gif" width=1 height=1 id="m_V' + t + '_1" name="m_V' + t + '_1"></td><td><a href="javascript:location.href=\''+ menuV[t][1] + '\';" class="topmenu"></td><td><img src="/sitedesign/'+standard+'/images/espace.png" width=8 height=1 border=0></td><td align="left"><a href="javascript:location.href=\''+ menuV[t][1] + '\';" class="topmenu" onMouseover="over(' + t + ');window.status=\''+ menuV[t][0] + '\';return true;" onMouseOut="MM_swapImgRestore();">'+ menuV[t][0] +'</a></td><td><img src="/sitedesign/'+standard+'/images/dot_trans.gif" width=1 height=1 id="m_V' + t + '_2" name="m_V' + t + '_2"></td><td bgcolor="#AB0D0D" width=33><img src="/sitedesign/'+standard+'/images/dhtml_puce.png"></td></tr><tr><td colspan=5 height=4></td></tr>';
		}
		else
		{
				HTML_V += '<tr><td><a href="javascript:location.href=\''+ menuV[t][1] + '\';" class="topmenu" onMouseover="over(' + t + ');" >' + menuV[t][0] + '</a></td></tr>';
		}	
	}
	HTML_V += '</table>';

	if (navigator.appVersion.indexOf("Mac",0)>0)
	{
		if (nn4) {
			document.menubarV.document.open();
			document.menubarV.document.write(HTML_V);
			document.menubarV.document.close();
			alert ( "nn4" );
		}
		else if (ie4)
		{
			menubarV.innerHTML = HTML_V;
			menuVL.top = ysPosV('posGifV');
			menuVL.left = xsPosV('posGifV');
			menuVL.visibility = "visible";
			menuVLoaded = true;		
		}
		else if (dom)
		{
			document.getElementById("menubarV").innerHTML = HTML_V;
			menuVL.top = ysPosV('posGifV');
			menuVL.left = xsPosV('posGifV');
			menuVL.visibility = "visible";
			menuVLoaded = true;	
		}	
	}
	else
	{	
		if (nn4) {
			document.menubarV.document.open();
			document.menubarV.document.write(HTML_V);
			document.menubarV.document.close();
			alert ( "nn4" );
		}
		else if (ie4)
		{
			menubarV.innerHTML = HTML_V;
			menuVL.top = ysPosV('posGifV') - 8;
			menuVL.left = xsPosV('posGifV');
			menuVL.visibility = "visible";
			menuVLoaded = true;		
		}
		else if (dom)
		{
			document.getElementById("menubarV").innerHTML = HTML_V;
			menuVL.top = ysPosV('posGifV');
			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 mouse movement
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-145 > xMax_V || mouse_Y_V < yMin_V || mouse_Y_V > yMax_V+20) && currentMenuV >=0 && menuVLoaded) {
//		alert('xMax_V=' + xMax_V + '<br>mouse_X_V=' + mouse_X_V);
		menuTimer = setTimeout('hideMenuV()',500);
	} else {
		clearTimeout(menuTimer);
	}
}

document.onmousemove = move;

function hideMenuV() {
	if ((mouse_X_V < xMin_V || mouse_X_V-145 > 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');

	HTML_V = '';
	if (menuV[what][2])
	{
	HTML_V += '<table cellpadding="1" cellspacing="1" border="0" valign="absmiddle"><tr><td bgcolor="#AB0D0D"><table cellpadding="3" cellspacing="0" border="0" bgcolor="#CDB89A">';
	for (t=2; t<=menuV[what].length-1; t=t+2) {
		if ((t+1)/2 == localPage && what == menuPageV) {
				HTML_V += '<tr><td class="menusub"><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');

	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 + 146;
	menuCV.top = y_V - 1;
	menuCV.visibility = "visible";
	// mouse-over area for menus
	if (ie4) {
		scrollPosV = document.body.scrollTop;
	}
	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 = "#AB0D0D";
	bg1V.style.color = "#CDB89A";
	bg1V.style.fontWeight = "normal";
}

function subOut(what) {
	if (ie4) {
		bg1V = eval('sub_V' + what);
	} else {
		bg1V = document.getElementById('sub_V' + what);	
	}
	bg1V.style.backgroundColor = "#CDB89A";
	bg1V.style.color = "#AB0D0D";
	bg1V.style.fontWeight = "normal";
}

function over(what) {
	if (currentMenuV > 0) {
		menuCV.visibility = "hidden";
	}
	currentMenuV = what;
	makemenuVcontent(what);
}

function out(what) {
	menuCV.visibility = "hidden";
	currentMenuV = 0;
}
