
var Popup_ns6 = document.getElementById && !document.all;

// get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table!
function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }
function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }
function getAbsPos(elt,which) {
 iPos = 0;
 while (elt != null) {
  iPos += elt["offset" + which];
  elt = elt.offsetParent;
 }
 return iPos;
}

function getObj(name)
{
	if(document.all) return document.all[name]; // IE4+
	if(document.getElementById) return document.getElementById(name); // IE5+, NS6
}

function ShowThemesPopup(x, y, theme)
{
	var ThemesContainer = getObj("ThemesContainer");
	ThemesContainer.style.left = x;
	ThemesContainer.style.top = y;

	var html = "<table border='0' cellpadding='0' cellspacing='0'><tr><td bgcolor='#cbcbcb'>";
	html += "<table border='0' cellspacing='0' cellpadding='0'>";
	for(var i=0; i<theme.length/2; i++)
	{
          html += "<tr><td><img src='/images/ombre_menu_haut_148.gif'  width='96'/></td></tr>";
          html += "<tr><td width='96' bgcolor='#cbcbcb'>&nbsp;<a onmouseover=\"this.parentElement.bgColor='#e5e5e5';\"  onmouseout=\"this.parentElement.bgColor='#cbcbcb';\" href='" + theme[i*2] + "' class='menulv2'>" + theme[i*2+1] + "</a></td></tr>";
          html += "<tr><td><img src='/images/ombre_menu_148.gif' width='96'/></td></tr>";
       }
	html += "</table>";
	html += "</td></tr></table>";

	ThemesContainer.innerHTML = html;
	ThemesContainer.style.display = '';

}

function HideThemesPopup()
{
	var ThemesContainer = document.getElementById("ThemesContainer");
	ThemesContainer.style.display = 'none';
}

function contains_ns6(a, b)
{
	while (b.parentNode)
		if ((b = b.parentNode) == a)
			return true;
		return false;
}

function CheckThemesHiding(o, e)
{
	if(Popup_ns6)
		return !contains_ns6(o, e.relatedTarget);
	else
		return !o.contains(e.toElement);
}

// window popup centered on screen
/*function Popup(url, target, width, height, resizable)
{
	if(width && height)
	{
		var left = (screen.width - width) / 2;
		var top = (screen.height - height) / 2;
	}
		var poptions = "left=" + left + ":px, top=" + top + ":px, width=" + width + "px, height=" + height + "px, resizable=" + (resizable?"yes":"no") + ", scrollbars=yes, location=no, menubar=no, status=no, toolbar=no";
	  window.open(url, target, poptions);
	}
	else
	{
		var poptions = "resizable=" + (resizable=="resizable"?"yes":"no") + ", scrollbars=yes, location=no, menubar=no, status=no, toolbar=no";
		window.open(url, target, poptions);
	}
}*/

function Popup(url, target, width, height, resizable)
{
	if(width && height)
	{
		var left = (screen.width - width) / 2;
		var top = (screen.height - height) / 2;
	}

	var poptions = "";
	if(left) poptions += "left=" + left;

	if(top) {
		if(poptions != "") poptions += ", ";
		poptions += "top=" + top;
	}

	if(width && width!="")
	{
		if(poptions != "") poptions += ", ";
		poptions += "width=" + width;
	}
	if(height && height!="")
	{
		if(poptions != "") poptions += ", ";
		poptions += "height=" + height;
	}

	if(resizable==true || resizable==false)
	{
		if(poptions != "") poptions += ", ";
		poptions += "resizable=" + (resizable==true?"yes":"no");
	}
	else
	{
		if(poptions != "") poptions += ", ";
		poptions += "resizable=yes";
	}

	if(width!="" && height!="")
	{
		if(poptions != "") poptions += ", ";
		poptions += "location=no, menubar=no, status=no, toolbar=no";
	}

	if(poptions != "") poptions += ", ";
	poptions += "scrollbars=yes";

	window.open(url, target, poptions);
}

function swapMenuOver(id, navimage, obj)
{
	MM_swapImage('puce_'+id,'','/images/puce-rouge.gif', 'navigationimage','',navimage);
	obj.parentElement.bgColor='#e5e5e5';
}

function swapMenuOut(obj)
{
	MM_swapImgRestore();
	obj.parentElement.bgColor='#cbcbcb';
}
