if (document.all)    {n=0;ie=1;fShow="visible";fHide="hidden";}
if (document.layers) {n=1;ie=0;fShow="show";   fHide="hide";}

msieIndex = navigator.appVersion.indexOf("MSIE")+5;
var mamarge;
if(parseFloat(navigator.appVersion.substr(msieIndex,3))=="5.5"||parseFloat(navigator.appVersion.substr(msieIndex,3))=="6")
{
mamarge=0
}else{
mamarge=40
}


window.onerror=new Function("return true")
rightX = 0;
document.write("<table border=0 cellspacing=0 cellpadding=0 bgcolor=#000000>");
document.write("<tr>");
if (ie)
{
document.write("<td colspan=2 align=center>");
//Tableau imbriqué pour IE uniquement
document.write("<table border=0 cellpadding=0 cellspacing=0 width=777>");
}

function Menu()
{
	this.bgColor = "#ffffff";
	if (ie) this.menuFont = "bold xx-small arial";
	if (n)  this.menuFont = "bold x-small arial";
	this.ajout = ajout;
	this.ajoutsous = ajoutsous;
	this.faitmenu = faitmenu;
	this.border = 0;
	this.sousborder = 1;
	this.souslongeur = 150;
	this.souscouleurbord = "#0099FF";
	lastMenu = null;
	rightY = 0;
	leftY = 0;
	leftX = 0;

	HTMLstr = "";
	HTMLstr += "<!-- MENU PANE DECLARATION BEGINS -->\n";
	HTMLstr += "\n";
	if (ie) HTMLstr += "<div id='MainTable' style='position:relative'>\n";
	HTMLstr += "<table cellspacing=0 cellpadding=0 width='776' border=1 bordercolor=#000031'>\n";
	HTMLstr += "<tr>";
	HTMLstr += "<!-- MAIN MENU STARTS -->\n";
	HTMLstr += "<!-- MAIN_MENU -->\n";
	HTMLstr += "<!-- MAIN MENU ENDS -->\n";
	HTMLstr += "</tr>\n";
	HTMLstr += "</table>\n";
	
	//id (xxx)
	//{
	//HTMLstr += "</td><td background=images/degrade.gif width=30 >&nbsp;</td></tr></table>\n";
	//}
	HTMLstr += "\n";
	HTMLstr += "<!-- SUB MENU STARTS -->\n";
	HTMLstr += "<!-- SUB_MENU -->\n";
	HTMLstr += "<!-- SUB MENU ENDS -->\n";
	HTMLstr += "\n";
	if (ie) HTMLstr+= "</div>\n";
	HTMLstr += "<!-- MENU PANE DECALARATION ENDS -->\n";
}


function displaySubMenu(idMainMenu)
{
 	var menu;
	var submenu;
	if (n)
	{
		submenu = document.layers[idMainMenu+"submenu"];
		if (lastMenu != null && lastMenu != submenu) hideAll();
		submenu.left = document.layers[idMainMenu].pageX;
		submenu.top  = document.layers[idMainMenu].pageY + 25;
		submenu.visibility = fShow;

		leftX  = document.layers[idMainMenu+"submenu"].left;
		rightX = leftX + document.layers[idMainMenu+"submenu"].clip.width;
		leftY  = document.layers[idMainMenu+"submenu"].top+
			document.layers[idMainMenu+"submenu"].clip.height;
		rightY = leftY;
	} else if (ie) {
		menu = eval(idMainMenu);
		submenu = eval(idMainMenu+"submenu.style");
		submenu.left = calmarge(menu, 'offsetLeft')-mamarge;
		submenu.top  = menu.style.top+23;
		submenu.visibility = fShow;
		
		if (lastMenu != null && lastMenu != submenu){hideAll();}
				
		
		leftX  = document.all[idMainMenu+"submenu"].style.posLeft;
		rightX = leftX + document.all[idMainMenu+"submenu"].offsetWidth;

		leftY  = document.all[idMainMenu+"submenu"].style.posTop+
			document.all[idMainMenu+"submenu"].offsetHeight;
		rightY = leftY;
		
	}
	lastMenu = submenu;
	
}

var letd;
var count;
count=0;

function col1(iddutd)
{
  letd=eval(iddutd);
  letd.style.backgroundColor='#000063';
  setTimeout("col2(letd)",1000);
  count+=1;
}

function col2(iddutd)
{
  iddutd.style.backgroundColor='#3399FF'
  setTimeout("initcol()",1800);
  count-=1;
}

var i;
i=0;
function initcol()
{
  rub1.style.backgroundColor='#3399FF'
  rub2.style.backgroundColor='#3399FF'
  rub3.style.backgroundColor='#3399FF'
  rub4.style.backgroundColor='#3399FF'
}

function ajout(idItem, text, hint, location, altLocation)
{
	var Lookup = "<!-- ITEM "+idItem+" -->";
	if (HTMLstr.indexOf(Lookup) != -1)
	{
		alert(idParent + " already exist");
		return;
	}
	var MENUitem = "";
	MENUitem += "\n<!-- ITEM "+idItem+" -->\n";
	if (n)
	{
		MENUitem += "<td valign=top align=center bgcolor=#3366FF><ilayer name="+idItem+" >";
		if(location!="pas")
		{
		MENUitem += "<a href='"+location+"' class=clsMenuItemNS onmouseover=\"displaySubMenu('"+idItem+"')\"";
		}else{
		MENUitem += "<a href=http://www.carexplorer.net class=clsMenuItemNS onmouseover=\"displaySubMenu('"+idItem+"')\"";
		}
		MENUitem += "target=_top>";
		MENUitem += text;
		MENUitem += "</a>";
		MENUitem += "</ilayer></td>";
	}
	if (ie)
	{
		if(altLocation=="pas")
		{
		MENUitem += "<td id=\"'"+idItem+"'\" bordercolor=#3366FF bgColor=#3399FF >\n";
		MENUitem += "<div id='"+idItem+"' style='position:relative; font: "+this.menuFont+";' align=center onclick=\"location.href='"+altLocation+"';\">\n";
		}else{
		MENUitem += "<td id=\"'"+idItem+"'\" bordercolor=#3366FF bgColor=#3399FF>\n";
		MENUitem += "<div id='"+idItem+"' style='position:relative; font: "+this.menuFont+";' align=center onclick=\"location.href='"+altLocation+"';\" onmouseover=\"displaySubMenu('"+idItem+"');\">\n";
		}
		MENUitem += "<a href=http://www.carexplorer.net target=_top>";
		MENUitem += "<font face=arial color=#FFFFFF size=2 style=\"text-decoration:none;\">";
		MENUitem += text;
		MENUitem += "</a>\n";
		MENUitem += "</div>\n";
		MENUitem += "</td>\n";
		
	}
	MENUitem += "<!-- END OF ITEM "+idItem+" -->\n\n";
	MENUitem += "<!-- MAIN_MENU -->\n";

	HTMLstr = HTMLstr.replace("<!-- MAIN_MENU -->\n", MENUitem);
}


function ajoutsous(idParent, text, hint, location)
{
	var MENUitem = "";
	Lookup = "<!-- ITEM "+idParent+" -->";
	if (HTMLstr.indexOf(Lookup) == -1)
	{
		alert(idParent + " not found");
		return;
	}
	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->";
	if (HTMLstr.indexOf(Lookup) == -1)
	{
		if (n)
		{
			MENUitem += "\n";
			MENUitem += "<layer id='"+idParent+"submenu' visibility=hide bgcolor='"+this.bgColor+"'>\n";
			MENUitem += "<table  border=1 cellspacing=0 cellpadding=0 bgcolor=#0066B3 width=200 >\n";
			MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
			MENUitem += "</table>\n";
			MENUitem += "</layer>\n";
			MENUitem += "\n";
		}
		if (ie)
		{
			MENUitem += "\n";
			MENUitem += "<div  align=left id='"+idParent+"submenu' style='position:absolute; visibility: hidden; width: "+this.souslongeur+"; font: "+this.menuFont+"; top: -300;';>\n";
			MENUitem += "<br><br><br><br><br><br><table  border=0 cellspacing=1 cellpadding=2 bgcolor=#0066B3 width=200 >\n";
			MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
			MENUitem += "</table>\n";
			MENUitem += "</div>\n";
			MENUitem += "\n";
		}
		MENUitem += "<!-- SUB_MENU -->\n";
		HTMLstr = HTMLstr.replace("<!-- SUB_MENU -->\n", MENUitem);
	}

	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
	if (n)  MENUitem = "<tr><td bgcolor=#FAFCFE onclick=\"location.href='"+location+"';\" ><font style=\"text-decoration:none;\" face=arial color=#165DB1 size=2><b><a href='"+location+"'><font style=\"text-decoration:none;\" face=arial color=#165DB1 size=2><b>"+text+"</a></td></tr>\n";
	if (ie) MENUitem = "<tr><td bgcolor=#FAFCFE onclick=\"top.location.href='"+location+"';\" onMouseOver=this.bgColor='#CDE7FF'; onMouseOut=this.bgColor='#FFFFFF'><a href='"+location+"' target=_top><font face=arial color=#165DB1 size=2 style=\"text-decoration:none;\"><b>"+text+"</a><br></td></tr>\n";
	MENUitem += Lookup;
	HTMLstr = HTMLstr.replace(Lookup, MENUitem);

}

function faitmenu()
{
	document.writeln(HTMLstr);
}

function hideAll()
{
	if (lastMenu != null) {lastMenu.visibility = fHide;lastMenu.left = 50;}
}

function calmarge(idItem, offsetName)
{
	var totalOffset = 0;
	var item = eval('idItem');
	do
	{
		totalOffset += eval('item.'+offsetName);
		item = eval('item.offsetParent');
	} while (item != null);
	return totalOffset;
}

function updateIt(e)
{

	if (ie)
	{
		var x = window.event.clientX;
		var y = window.event.clientY;

		if (x > rightX || x < leftX){hideAll();}
		else if (y > rightY){hideAll();}
	}
	if (n)
	{
		var x = e.pageX;
		var y = e.pageY;

		if (x > rightX || x < leftX) hideAll();
		else if (y > rightY) hideAll();
	}
}
if (document.all)
{
	document.body.onclick=hideAll;
	document.body.onscroll=hideAll;
	document.body.onmousemove=updateIt;
}
if (document.layers)
{
	document.onmousedown=hideAll;
	//window.captureEvents(Event.MOUSEMOVE);
	window.onmousemove=updateIt;
}

