var gTimerPubID = 0;
var gPosPub = 0;
var gTimerID  = 0;
var gOpacity = 100;
var gMenuOpen = 0;

/////////////////////////////////////////////////////////////////////////////////
function movepic(img_name,img_src)
{
	document[img_name].src=img_src;
}
/////////////////////////////////////////////////////////////////////////////////
function OpenMenu()
{
	menu = document.getElementById("menuDiv").style;
	menu.left = event.clientX - 200;
	menu.top = 90;
   	menu.visibility = "visible";
   	gMenuOpen = 1;
}
/////////////////////////////////////////////////////////////////////////////////
function MenuOver()
{
	gMenuOpen = 1;
}

/////////////////////////////////////////////////////////////////////////////////
function CloseMenu()
{
	gMenuOpen = 0;
	gTimerID  = setTimeout("MenuUpdateTimer()", 1000);
}
/////////////////////////////////////////////////////////////////////////////////
function MenuUpdateTimer()
{
	if(gTimerID)
		clearTimeout(gTimerID);
	if(!gMenuOpen)
	{
		menu = document.getElementById("menuDiv").style;
		menu.visibility = "hidden";
	}
}
/////////////////////////////////////////////////////////////////////////////////
function OpenTipBox()
{
	tip = document.getElementById("tipDiv").style;
   	tip.left = event.clientX + document.body.scrollLeft + 20;
    tip.top = event.clientY + document.body.scrollTop + 20;
   	tip.visibility = "visible";
}
/////////////////////////////////////////////////////////////////////////////////
function MajTipBox(tipText,deltax,deltay)
{
	tip = document.getElementById("tipDiv").style;
   	tip.left = event.clientX + document.body.scrollLeft + deltax;
    tip.top = event.clientY + document.body.scrollTop + deltay;
	text = document.getElementById("tiptext");
	text.size = tipText.length;
	tip.width = tipText.length;
	text.value = tipText;
}
/////////////////////////////////////////////////////////////////////////////////
function CloseTipBox()
{
	tip = document.getElementById("tipDiv").style;
	tip.visibility = "hidden";
}
/////////////////////////////////////////////////////////////////////////////////
function IntroStartTimer()
{
	gTimerID  = setTimeout("IntroUpdateTimer()", 1);
}
/////////////////////////////////////////////////////////////////////////////////
function IntroUpdateTimer()
{
	if(gTimerID)
		clearTimeout(gTimerID);

   	gOpacity -= 1;
   	if(gOpacity <= 0)
   	{
	   	document.getElementById("introDiv").style.visibility = "hidden";
   		IntroStopTimer();
	}
   	else
   	{
	   var tempo = "alpha(Opacity=" + gOpacity + ")";
	   document.getElementById("introDiv").style.filter = tempo;	
	   gTimerID = setTimeout("IntroUpdateTimer()", 1);	   
	}
}
/////////////////////////////////////////////////////////////////////////////////
function IntroStopTimer()
{
   if(gTimerID)
   {
      clearTimeout(gTimerID);
      gTimerID  = 0;
   }
}
/////////////////////////////////////////////////////////////////////////////////
function getWinWidth()
{
	var w="";
	if (document.all)
		w=document.body.clientWidth;
	else
		w=window.innerWidth;
	return w;
}
/////////////////////////////////////////////////////////////////////////////////
function getWinHeight()
{
	var h="";
	if (document.all)
		h=document.body.clientHeight;
	else
		h=window.innerHeight;
	return h;	
}
/////////////////////////////////////////////////////////////////////////////////
function hideSubMenu(idSubMenu)
{
	oel = document.getElementById(idSubMenu);
	if(oel)
		oel.style.display = "none"; 
}
/////////////////////////////////////////////////////////////////////////////////
function showSubMenu(idSubMenu)
{
	// On cache tout
	nbSousMenu = 10;
	nbMenu = 10;
	for(j = 0 ; j < nbMenu ; j++)
		for(i = 0 ; i < nbSousMenu ; i++)
			hideSubMenu("menu" + j + "-submenu" + i);

	// On affiche celui voulu
	oel = document.getElementById(idSubMenu);
	if(oel)
		oel.style.display = "block"; 
}
/////////////////////////////////////////////////////////////////////////////////
function hideMenu(idMenu)
{
	oel = document.getElementById(idMenu);
	if(oel)
		oel.style.display = "none"; 
}
/////////////////////////////////////////////////////////////////////////////////
function showMenu(idMenu)
{
	// On cache tout
	nbMenu = 10;
	for(i = 0 ; i < nbMenu ; i++)
		hideSubMenu("menu" + i);
	
	// On affiche celui voulu
	oel = document.getElementById(idMenu);
	if(oel)
		oel.style.display = "block"; 
}
/////////////////////////////////////////////////////////////////////////////////
function hideAllSubMenu()
{
	// On cache tout
	nbSousMenu = 10;
	nbMenu = 10;
	for(j = 0 ; j < nbMenu ; j++)
		for(i = 0 ; i < nbSousMenu ; i++)
			hideSubMenu("menu" + j + "-submenu" + i);
}
/////////////////////////////////////////////////////////////////////////////////
function hideAllMenu()
{
	// On cache tout
	nbMenu = 10;
	for(j = 0 ; j < nbMenu ; j++)
		hideMenu("menu"+j);
}

/////////////////////////////////////////////////////////////////////////////////
 /**
 * Load page into content div
 **/
 function loadPage(url) {
        if (window.XMLHttpRequest) { // Non-IE browsers
         req = new XMLHttpRequest();
         req.onreadystatechange = targetDiv;
         try {
             req.open("GET", url, true);
         } catch (e) {
             alert(e);
         }
         req.send(null);
     } else if (window.ActiveXObject) { // IE
         req = new ActiveXObject("Microsoft.XMLHTTP");
         if (req) {
             req.onreadystatechange = targetDiv;
             req.open("GET", url, true);
             req.send();
         }
     }
 }

 /**
 *
 **/
 function targetDiv()
 {
     if (req.readyState == 4) // Complete
     {
         if (req.status == 200) { // OK response
             document.getElementById("content-text").innerHTML = req.responseText;
         } else {
             alert("Problem: " + req.statusText);
         }
     }
 }
