function afficheFiche(id,nb)
{
	for(var i = 0; i <nb ; i++)
	{
		document.getElementById('titreMenuPlat'+i).className = "";
		document.getElementById('onglet'+i).style.display = "none";
	}
	
	document.getElementById('onglet'+id).style.display = "block";
	document.getElementById('titreMenuPlat'+id).className = "blancNormal";
		
}

function tailleCache(objImage,id)
{
	if(document.getElementById(id))
		document.getElementById(id).style.height = objImage.height+"px";

}

function majContenu()
{
	document.getElementById('divInitial').style.display = "none";
	document.getElementById('maj').style.display = "block";
}

function cachemajContenu()
{
	document.getElementById('divInitial').style.display = "block";
	document.getElementById('maj').style.display = "none";
}


function majContenuProduit()
{
	document.getElementById('divInitialProduit').style.display = "none";
	document.getElementById('majProduit').style.display = "block";
}

function cachemajContenuProduit()
{
	document.getElementById('divInitialProduit').style.display = "block";
	document.getElementById('majProduit').style.display = "none";
}

function majFiche(id,id2)
{
	document.getElementById(id2).style.display = "none";
	document.getElementById(id).style.display = "block";
}

function cachemajFiche(id,id2)
{
	document.getElementById(id2).style.display = "block";
	document.getElementById(id).style.display = "none";
}




/*function afficheDivInfo(x,y)
{
	document.getElementById('info').style.display = "block";
	document.getElementById('info').style.opacity = "0.3";

	document.getElementById('info').style.top =  x+"px";
	document.getElementById('info').style.left = y+"px";
}

function cacheDivInfo()
{
	document.getElementById('info').style.display = "none";
}

function WhereMouse( e ){
  var DocRef;    // Variable pour IE uniquement

  // L'événement est passée à la fonction
  // donc tous sauf IE…
  if( e){                     // Dans ce cas on obtient directement la position dans la page
    Mouse_X = e.pageX;
    Mouse_Y = e.pageY;
  }
  else{                      // Dans ce cas on obtient la position relative à la fenêtre d'affichage
    Mouse_X = event.clientX;
    Mouse_Y = event.clientY;

    //-- Il faut traiter le CAS des DOCTYPE sous IE
    if( document.documentElement && document.documentElement.clientWidth) // Donc DOCTYPE
      DocRef = document.documentElement;   // Dans ce cas c'est documentElement qui est réfèrence
    else
      DocRef = document.body;                    // Dans ce cas c'est body qui est réfèrence

    //-- On rajoute la position liée aux ScrollBars
    Mouse_X += DocRef.scrollLeft;
    Mouse_Y += DocRef.scrollTop;
  }
 afficheDivInfo(Mouse_X,Mouse_Y);
}*/

/*var positionCurseurX;
var positionCurseurY;*/

function startShowEditMenu(){
	document.getElementById('info').style.display = "block";
	//document.getElementById('contenuInitial').style.border = '1px solid #b9d274';
	document.getElementById('contenuInitial').style.border = '1px solid #DC6C08';

}

function stopShowEditMenu()
{	document.getElementById('info').style.display = "none";
	document.getElementById('contenuInitial').style.border = 0;
}


function startShowEditMenuProduit(){
	document.getElementById('infoProduit').style.display = "block";
	//document.getElementById('contenuInitial').style.border = '1px solid #b9d274';
	document.getElementById('divInitialProduit').style.border = '1px solid #DC6C08';

}

function stopShowEditMenuProduit()
{	document.getElementById('infoProduit').style.display = "none";
	document.getElementById('divInitialProduit').style.border = 0;
}

function startShowEditMenu2(fiche,info){
	document.getElementById(info).style.display = "block";
	document.getElementById(fiche).style.border = '1px solid #b9d274';	

}

function stopShowEditMenu2(fiche,info)
{	document.getElementById(info).style.display = "none";
	document.getElementById(fiche).style.border = 0;
}

/*function position(e) {
	if (navigator.appName.substring(0,3) == "Net") {
		positionCurseurX = e.pageX;
		positionCurseurY = e.pageY;
	}
	else {
		positionCurseurX = event.x + document.body.scrollLeft;
		positionCurseurY = event.y + document.body.scrollTop;
	}
}

if(navigator.appName.substring(0,3) == "Net") document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = position;
*/


function redimProduits()
{	blocProduits = document.getElementById("menuProduits");
	blocLangues = document.getElementById("langues");
	blocActualites = document.getElementById("menuActualites");
	blocGauche = document.getElementById("gauche");
	cumulMarginProduits = parseInt(blocProduits.style.marginBottom.replace("px", ""));
	cumulPaddingProduits = parseInt(blocProduits.style.paddingTop.replace("px", "")) + parseInt(blocProduits.style.paddingBottom.replace("px", ""));
	hauteurADeduire = blocActualites.offsetHeight + blocLangues.offsetHeight + cumulMarginProduits + cumulPaddingProduits + 11;

blocProduits.style.height = (blocGauche.offsetHeight - hauteurADeduire) + "px";

}

window.onload = function() { redimProduits(); } ;


function colorier(td,idMois,idProduit,langue)
{
	
	td.style.background = '#DC6C08';
	document.getElementById("mois"+idMois).style.color = '#DC6C08';	
	document.getElementById("produit"+idProduit).style.color = '#DC6C08';	
	
	
	//recuperation des info du produit pour le mois donnée en AJAX
	var xhr = null;
	 if (window.XMLHttpRequest) // Firefox et autres
	 {
	  xhr = new XMLHttpRequest();
	 }
	 else if (window.ActiveXObject) // Internet Explorer
	 {
	  try
	  {
	   xhr = new ActiveXObject("Microsoft.XMLHTTP" );
	  }
	  catch (e)
	  {
	   try
	   {
	    xhr = new ActiveXObject("Msxml2.XMLHTTP" );
	   }
	   catch (e1)
	   {
	    xhr = null;
	   }
	     }
	}


    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {    
              if(xhr.status  == 200) 
              {
				var rep = xhr.responseText;
				var reg=new RegExp("\n", "g");
				rep = rep.replace(reg,"");	
				var reg=new RegExp("\t", "g");
				rep = rep.replace(reg,"");
				var reg=new RegExp("\r", "g");
				rep = rep.replace(reg,"");
				
	              	if(rep.length > 0 )
	                {
					
	              		document.getElementById("infoProduit").innerHTML = xhr.responseText;
	              		document.getElementById("infoProduit").style.display = 'block';	// ca merde
	              		var toptable =  document.getElementById("tableauConditionnement").offsetTop;
	              		var lefttable =  document.getElementById("tableauConditionnement").offsetLeft;
	              		
	              		//alert("top table : "+toptable+"\nleft table : "+lefttable);
	              		
	              		var taille = document.getElementById("infoProduit").offsetHeight;
	              			              		
	              		document.getElementById("infoProduit").style.top = td.offsetTop + toptable - taille +"px";	
	              		document.getElementById("infoProduit").style.left = td.offsetLeft + lefttable + "px";
						document.getElementById("infoProduit").style.borderLeft = "1px solid #DC6C08";
						document.getElementById("infoProduit").style.borderTop = "10px solid #DC6C08";						
              			nom = navigator.appName;
						if(nom  == 'Microsoft Internet Explorer')
						{
							vers = navigator.appVersion;
							var chaine = vers.split(";");
							chaine = chaine[1];
							//alert(chaine);
							//if(vers == "4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)")
							if(chaine == " MSIE 7.0")
							{
								//alert("pooopopopooppopopop");
								var taille = document.getElementById("infoProduit").style.top;
								taille = taille.split("px");
								
								taille2 = taille[0];
								var nombre = 300;
								taille2 =parseInt(taille2) + nombre;			
								document.getElementById("infoProduit").style.top = taille2+"px";	
							}
						}
	          		}
	          		
              } 
         }
    }; 

   xhr.open("GET", "getInfoProduit.php?mois="+idMois+"&id="+idProduit+"&langue="+langue,true);
   xhr.send(null);
	
}

function decolorier(td,idMois,idProduit)
{
	td.style.background = '#646464';
	document.getElementById("mois"+idMois).style.color = '#FFFFFF';	
	document.getElementById("produit"+idProduit).style.color = '#FFFFFF';	
	document.getElementById("infoProduit").style.display = 'none';
}

function afficheTableauProduction()
{
	javascript:document.getElementById('surimpression').style.display ='block';	
	javascript:document.getElementById('ombre').style.display ='block';	
}

function cacheTableauProduction()
{
	javascript:document.getElementById('surimpression').style.display ='none';	
	javascript:document.getElementById('ombre').style.display ='none';
}
