// -------------------------------------------------------------
// Fonctions utiles
// -------------------------------------------------------------

// ------------------------------------------
function setWindowHeight()
{
	var windowHeight=0;
	// If pour IE
	if (typeof(window.innerHeight) == "number")
	{
		windowHeight=window.innerHeight;
	}
	else
	{
		if (document.documentElement&&document.documentElement.clientHeight)
		{
			windowHeight = document.documentElement.clientHeight;
		}
		else
		{
			if (document.body&&document.body.clientHeight)
			{
				windowHeight=document.body.clientHeight;
			}
		}
	}
	// Moins la hauteur du bandeau+pied
	windowHeight -= 195;
	var el = document.getElementById("emballage");
	el.style.height = windowHeight+"px";
}


// ------------------------------------------
function checkAll(checkname, exby, bloc)
{
	var monbloc = document.getElementById(bloc);
	var mesinputs = monbloc.getElementsByTagName("input" );
	for (var i=1; i<mesinputs.length; i++) {
		mesinputs[i].checked = exby.checked? true:false
	}
	//for (i = 0; i < checkname.outputInd[0].length; i++)
	//	checkname.outputInd[0][i].checked = exby.checked? true:false
}

// ------------------------------------------
function tips(dest, texte)
{
	if (texte)
    {
    	dest.innerHTML = texte;
    	dest.style.display = "block";
    }
    else
    {
    	dest.innerHTML = "";
    	dest.style.display = "none";
    }
}
// ------------------------------------------
function alertBox(text, icon, functionBt)
{
	// --------------------------------------
	// 
	if (functionBt == "") 
		document.getElementById("submit").style.display = "none";
	else
		document.getElementById("submit").style.display = "inline";
	// --------------------------------------
	var IsIE=!!document.all;
	if (!IsIE)
	{
		document.onkeypress = function(event)
		{
			if(event.keyCode == "27" | event.keyCode == "13")
			{
				document.getElementById("hide").style.display = "none";
				document.getElementById("alert").style.display = "none";
			}
		}
	}
	// --------------------------------------
	document.getElementById("hide").style.display = "block";
	var IsIE=!!document.all;
	var el = document.getElementById("hide");
	if(IsIE)
		el.style.filter='alpha(opacity=60)';
	else
		el.style.opacity=0.6;
	document.getElementById("alert").style.display = "block";
	var el = document.getElementById("alertText");
		el.innerHTML = text;
	// --------------------------------------
	var el = document.getElementById("alert");
	if (icon == "error")
		el.className = "error";
	else
		el.className = "warning";
	// --------------------------------------
	// Gestion des boutons
	document.getElementById("cancel").onclick = function()
	{
		document.getElementById("hide").style.display = "none";
		document.getElementById("alert").style.display = "none";
	}
	document.getElementById("submit").onclick = function()
	{
		document.getElementById("hide").style.display = "none";
		document.getElementById("alert").style.display = "none";
		eval(functionBt);
	}
	// --------------------------------------
}
// ------------------------------------------
function progressBar(percent, text)
{
	// --------------------------------------
	// Affichage
	box = document.getElementById("progression");
	if (box.style.display != "block")
	{
		document.getElementById("hide").style.display = "block";
		var IsIE=!!document.all;
		var el = document.getElementById("hide");
		if(IsIE)
			el.style.filter='alpha(opacity=60)';
		else
			el.style.opacity=0.6;
		box.style.display = "block";
	}
	document.getElementById("progressionText").innerHTML = text;
	document.getElementById("progressionStatus").style.width = percent+"%";
	// --------------------------------------
	// Gestion des boutons
	document.getElementById("cancelRun").onclick = function()
	{
		document.getElementById("hide").style.display = "none";
		document.getElementById("progression").style.display = "none";
	}
	// --------------------------------------
}
// ------------------------------------------
// Permet d'arrondir &agrave; 3 chiffres apres la virgule
function around(nb)
{
	var x = (Math.ceil(nb*1000))/1000;
	return x;
}
