// JavaScript Document
function getMesure(lst){
	var valeur = lst.value ;
	var path = "" ;
	switch (valeur){
		case "cap_liq" :
			path = "/calculatrice/liquide.asp"
		break;
		case "long" :
			path = "/calculatrice/longueur.asp"		
		break; 
		case "poids" :
			path = "/calculatrice/poids.asp"		
		break;
		case "surface" :
			path = "/calculatrice/surface.asp"		
		break;
		case "volume" :
			path = "/calculatrice/volume.asp"
		break;
		case "qte_ceramique":
			path = "/calculatrice/ceramique.asp"
		break;
		case "qte_gypse" :
			path = "/calculatrice/gypse.asp"
		break;		
		case "qte_fibverre" :
			path = "/calculatrice/isolant.asp" 
		break;
		case "qte_pappeint" : 
			path = "/calculatrice/papierpeint.asp" 
		break;
		case "qte_peinture" :
			path = "/calculatrice/peinture.asp"
		break;
		case "qte_tapis" : 
			path = "/calculatrice/tapis.asp" 
		break;
	}
	if(path!=""){window.open(path,'calculatrice','toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=0, copyhistory=0, menuBar=0, width=480, height=460');}
}

function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}

function cal1Capacite(txt)
{
	var sizeValue;
	var mainValue;
	var literValue;
	
	sizeValue = parseFloat(document.Len.Sranges.options[document.Len.Sranges.selectedIndex].value);
	mainValue = document.forms[0].mainValue.value;
	if (mainValue != "")
		{
			if (isNaN(mainValue))
			{
				alert(txt);		
			}
			else
			{
			meterValue = parseFloat(mainValue) / sizeValue;
			document.forms[0].millilitre.value= floor(meterValue * 1000);
			document.forms[0].litre.value= floor(meterValue * 1);
			document.forms[0].once.value= floor(meterValue * 33.8239926);
			document.forms[0].gallon.value = floor(meterValue * 0.2642499);
			}
		}
}

function cal1Longeur(txt)
{
	var sizeValue;
	var mainValue;
	var meterValue;
	var metre;
	
	sizeValue = parseFloat(document.forms[0].Sranges.options[document.forms[0].Sranges.selectedIndex].value);
	mainValue = document.forms[0].mainValue.value;
	
	if (mainValue != "")
	{
		if (isNaN(mainValue))
		{
			alert(txt);
		}
		else
		{
			meterValue = parseFloat(mainValue) / sizeValue;
			document.forms[0].centimetre.value = floor(meterValue * 100);
			document.forms[0].metre.value= floor(meterValue);
			document.forms[0].pouce.value= floor(meterValue * 39.37007874);
			document.forms[0].pied.value = floor(meterValue * 3.280839895);
			document.forms[0].verge.value= floor(meterValue * 1.093613298);
		}
	}
}

function cal1Poids(txt)
{
var sizeValue;
var mainValue;
var kilogramValue;

sizeValue = parseFloat(document.Len.Sranges.options[document.Len.Sranges.selectedIndex].value);
mainValue = document.forms[0].mainValue.value;

if (mainValue != "")
	{
		if (isNaN(mainValue))
		{
			alert(txt);
		}
		else
		{
			KilogramValue = parseFloat(mainValue) / sizeValue;
			document.forms[0].gram.value= floor(KilogramValue * 1000);
			document.forms[0].kilogram.value= floor(KilogramValue * 1);
			document.forms[0].ounce.value= floor(KilogramValue * 35.273944);
			document.forms[0].pound.value = floor(KilogramValue * 2.2046215);
		}
	}
}

function cal1Surface(txt)
{
var sizeValue;
var mainValue;
var MeterValue;

sizeValue = parseFloat(document.Len.Sranges.options[document.Len.Sranges.selectedIndex].value);
mainValue = document.forms[0].mainValue.value;

if (mainValue != "")
{
		if (isNaN(mainValue))
		{
			alert(txt);
		}
		else
		{

		meterValue =parseFloat(mainValue) / sizeValue;
		document.forms[0].centimetre.value= floor(meterValue * 10000);
		document.forms[0].metre.value= floor(meterValue * 1);
		document.forms[0].inch.value= floor(meterValue * 1549.997);
		document.forms[0].foot.value = floor(meterValue * 10.765);
		document.forms[0].yard.value= floor(meterValue * 1.196);
		}
	}
}

function cal1Volume(txt)
{
var sizeValue;
var mainValue;
var meterValue;

sizeValue = parseFloat(document.Len.Sranges.options[document.Len.Sranges.selectedIndex].value);
mainValue = document.forms[0].mainValue.value;

if (mainValue != "")
	{
		if (isNaN(mainValue))
		{
			alert(txt);
		}
		else
		{

		meterValue = parseFloat(mainValue) / sizeValue;
		document.forms[0].centimetre.value= floor(meterValue * 1000000);
		document.forms[0].metre.value= meterValue * 1;
		document.forms[0].inch.value= meterValue * 61023.3819;
		document.forms[0].foot.value = meterValue * 35.317812;
		document.forms[0].yard.value= meterValue * 1.3079456;
		}
	}
}

function validateCeramique(msg1,msg2,msg3)
{
var pass = "yes"
var msg = ""
var Length
var width

Length = document.Len.Length.value
width = document.Len.width.value
	if  (isNaN(Length) || Length == " " || Length == null || Length == "") 
		{
		msg =  msg1
		pass = "no";
		}
	if  (isNaN(width) || width == " " || width == null  || width == "") 
		{
		msg = msg + msg2
		pass = "no";
		}	
if (pass=="yes")
	{
		document.Len.submit();	
	}
else
	{
	alert(msg3 + msg);
	return (false);
	}
}

function validateGypse(lang)
{
var pass = "yes"
var msg2 = ""
var msg1 = ""
var Length
var width

heightWall1 = document.Len.heightWall1.value
heightWall2 = document.Len.heightWall2.value
heightWall3 = document.Len.heightWall3.value
heightWall4 = document.Len.heightWall4.value
heightWall5 = document.Len.heightWall5.value

WidthWall1 = document.Len.WidthWall1.value
WidthWall2 = document.Len.WidthWall2.value
WidthWall3 = document.Len.WidthWall3.value
WidthWall4 = document.Len.WidthWall4.value
WidthWall5 = document.Len.WidthWall5.value

nondoor  = document.Len.nondoor.value
nonWindow = document.Len.nonWindow.value
nonOther = document.Len.nonOther.value

		if  (isNaN(heightWall1) || heightWall1 == " " || heightWall1 == null || heightWall1 == "") 
		{
		msg1 = ":Mur 1 hauteur \n";
		msg2 = ":Wall 1 Height \n";
		pass = "no";
		}
		if  (isNaN(heightWall2) || heightWall2 == " " || heightWall2 == null || heightWall2=="") 
		{
		msg1 = msg1 +  ":Mur 2 hauteur \n";
		msg2 = msg2 + ":Wall 2 Height \n";
		pass = "no";
		}
		if  (isNaN(heightWall3) || heightWall3 == " " || heightWall3 == null || heightWall3=="") 
		{
		msg1 = msg1 +  ":Mur 3 hauteur \n";
		msg2 = msg2 + ":Wall 3 Height \n";
		pass = "no";
		}
		if  (isNaN(heightWall4) || heightWall4 == " " || heightWall4 == null || heightWall4=="") 
		{
		msg1 = msg1 +  ":Mur 4 hauteur \n";
		msg2 = msg2 + ":Wall 4 Height \n";
		pass = "no";
		}
		if  (isNaN(heightWall5) || heightWall5 == " " || heightWall5 == null  || heightWall5=="") 
		{
		msg1 = msg1 +  ":Mur 5 hauteur \n";
		msg2 = msg2 + ":Ceiling  \n";
		pass = "no";
		}
		if  (isNaN(WidthWall1) || WidthWall1 == " " || WidthWall1 == null || WidthWall1 == " ")
		{
		msg1 = msg1 +  ":Mur 1 longueur \n";
		msg2 = msg2 + ":Wall 1 Length \n";
		pass = "no";
		}
		if  (isNaN(WidthWall2) || WidthWall2 == " " || WidthWall2 == null || WidthWall2 == "") 
		{
		msg1 = msg1 +  ":Mur 2 longueur \n";
		msg2 = msg2 + ":Wall 2 Length \n";
		pass = "no";
		}
		if  (isNaN(WidthWall3) || WidthWall3 == " " || WidthWall3 == null || WidthWall3 == "") 
		{
		msg1 = msg1 +  ":Mur 3 longueur \n";
		msg2 = msg2 + ":Wall 3 Length \n";
		pass = "no";
		}
		if  (isNaN(WidthWall4) || WidthWall4 == " " || WidthWall4 == null  || WidthWall4 == "")
		{
		msg1 = msg1 +  ":Mur 4 longueur \n";
		msg2 = msg2 + ":Wall 4 Length \n";
		pass = "no";
		}
		if  (isNaN(WidthWall5) || WidthWall5 == " " || WidthWall5 == null || WidthWall5 == "") 
		{
		msg1 = msg1 +  ":Mur 5 longueur \n";
		msg2 = msg2 + ":Ceiling  Length \n";
		pass = "no";
		}
		if  (isNaN(nondoor) || nondoor == " " || nondoor == null || nondoor == "") 
		{
		msg1 = msg1 +  ":dimension de la porte \n";
		msg2 = msg2 + ":Door  \n";
		pass = "no";
		}if  (isNaN(nonWindow) || nonWindow == " " || nonWindow == null || nonWindow == "") 
		{
		msg1 = msg1 +  ":dimension de la fenêtre  \n";
		msg2 = msg2 + ":Window \n";
		pass = "no";
		}if  (isNaN(nonOther) || nonOther == " " || nonOther == null  || nonOther == "") 
		{
		msg1 = msg1 +  ":dimension autre \n";
		msg2 = msg2 + ":Other \n";
		pass = "no";
		}
if (pass=="yes")
	{
	document.Len.submit();	
	}
else
	{
	if(lang==2){
		alert("Check your input in  \n" + msg2);
	}else{
		alert("Valider le(s) champ(s) :   \n" + msg1);
	}
	return (false);
	}
}


function validateIsolant(lang)
{
var pass = "yes";
var msg1 = "";
var msg2 = "";
var Length;
var width;

Length = document.Len.Length.value;
height = document.Len.height.value;
nondoor  = document.Len.nondoor.value;
nonWindow = document.Len.nonWindow.value;
nonOther = document.Len.nonOther.value;

		if  (isNaN(Length) || Length == " " || Length == null || Length == "") 
		{
		msg1 = ":Longeur  \n";
		msg2 = ":Length  \n";
		pass = "no";
		}
		if  (isNaN(height) || height == " " || height == null || height == "")
		{
		msg1 = msg1 + ":Hauteur \n";
		msg2 = msg2 + ":Height \n";
		pass = "no";
		}
		if  (isNaN(nondoor) || nondoor == " " || nondoor == null || nondoor == "") 
		{
		msg1 = msg1 + ":Porte  \n";
		msg2 = msg2 + ":Door  \n";
		pass = "no";
		}if  (isNaN(nonWindow) || nonWindow == " " || nonWindow == null || nonWindow == "") 
		{
		msg1 = msg1 + ":Fenêtre \n";
		msg2 = msg2 + ":Window \n";
		pass = "no";
		}if  (isNaN(nonOther) || nonOther == " " || nonOther == null  || nonOther == "") 
		{
		msg1 = msg1 + ":Autre \n";
		msg2 = msg2 + ":Other \n";
		pass = "no";
		}
if (pass=="yes")
	{
	document.Len.submit();	
	}
else
	{
		if(lang==2){
			alert("Check your input in  \n" + msg2);
		}else{
			alert("Valider le(s) champ(s) :  \n" + msg1);
		}
	return (false);
	}
}


function validatePeint(lang)
	{
		var pass = "yes";
		var msg1 = "";
		var msg1 = "";
		var Length;
		var width;
		
		heightWall1 = document.Len.heightWall1.value;
		heightWall2 = document.Len.heightWall2.value;
		heightWall3 = document.Len.heightWall3.value;
		heightWall4 = document.Len.heightWall4.value;

		WidthWall1 = document.Len.WidthWall1.value;
		WidthWall2 = document.Len.WidthWall2.value;
		WidthWall3 = document.Len.WidthWall3.value;
		WidthWall4 = document.Len.WidthWall4.value;

		nondoor  = document.Len.nondoor.value;
		nonWindow = document.Len.nonWindow.value;
		nonOther = document.Len.nonOther.value;

		if  (isNaN(heightWall1) || heightWall1 == " "  ||  heightWall1 == null) 
		{
			msg1 = ":Mur 1 Hauteur \n";
			msg2 = ":Wall 1 Height \n";
			pass = "no";
		}
		if  (isNaN(heightWall2) || heightWall2 == " "  ||  heightWall2 == null)
		{
			msg1 = msg1 + ":Mur 2 Hauteur \n";
			msg2 = msg2 + ":Wall 2 Height \n";
			pass = "no";
		}	
		if  (isNaN(heightWall3) || heightWall3 == " "  ||  heightWall3 == null)
		{
			msg1 = msg1 + ":Mur 3 Hauteur \n";
			msg2 = msg2 + ":Wall 3 Height \n";
			pass = "no";
		}
		if  (isNaN(heightWall4) || heightWall4 == " "  ||  heightWall4 == null)
		{
			msg1 = msg1 + ":Mur 4 Hauteur \n";
			msg2 = msg2 + ":Wall 4 Height \n";
			pass = "no";
		}		
		if  (isNaN(WidthWall1) || WidthWall1 == " " ||  WidthWall1 == null)
		{
			msg1 = msg1 + ":Mur 1 Longueur \n";
			msg2 = msg2 + ":Wall 1 Length \n";
			pass = "no";
		}
		if  (isNaN(WidthWall2) || WidthWall2 == " " ||  WidthWall2 == null)
		{
			msg1 = msg1 + ":Mur 2 Longueur \n";
			msg2 = msg2 + ":Wall 2 Length \n";
			pass = "no";
		}	
		if  (isNaN(WidthWall3) || WidthWall3 == " " ||  WidthWall3 == null)
		{
			msg1 = msg1 + ":Mur 3 Longueur \n";
			msg2 = msg2 + ":Wall 3 Length \n";
			pass = "no";
		}
		if  (isNaN(WidthWall4) || WidthWall4 == " " ||  WidthWall4 == null)
		{
			msg1 = msg1 + ":Mur 4 Longueur \n";
			msg2 = msg2 + ":Wall 4 Length \n";
			pass = "no";
		}		
		if  (isNaN(nondoor) || nondoor == " " || nondoor == null)
		{
			msg1 = msg1 + ":Porte  \n";
			msg2 = msg2 + ":Door  \n";
			pass = "no";
		}
		if  (isNaN(nonWindow) || nonWindow == " " || nonWindow == null)
		{
			msg1 = msg1 + ":Fenêtre \n";
			msg2 = msg2 + ":Window \n";
			pass = "no";
		}	
		if  (isNaN(nonOther) || nonOther == " " || nonOther == null) 
		{
			msg1 = msg1 + ":Autre \n";
			msg2 = msg2 + ":Other \n";
			pass = "no";
		}
	if (pass=="yes")
	{
		document.Len.submit();	
	}
	else
	{	
		if(lang==1){	
			alert("Valider le(s) champ(s) :   \n" + msg1);
		}else{
			alert("Check your input in  \n" + msg2);
		}
		return (false);
	}
}

function validatePeinture(lang)
	{
		var pass = "yes";
		var msg1 = "";
		var msg2 = "";
		var Length;
		var width;

		heightWall1 = document.Len.heightWall1.value;
		heightWall2 = document.Len.heightWall2.value;
		heightWall3 = document.Len.heightWall3.value;
		heightWall4 = document.Len.heightWall4.value;
		heightCeiling = document.Len.heightCeiling.value;

		WidthWall1 = document.Len.WidthWall1.value;
		WidthWall2 = document.Len.WidthWall2.value;
		WidthWall3 = document.Len.WidthWall3.value;
		WidthWall4 = document.Len.WidthWall4.value;
		WidthCeiling = document.Len.WidthCeiling.value;

		nondoor  = document.Len.nondoor.value;
		nonWindow = document.Len.nonWindow.value;
		nonOther = document.Len.nonOther.value;

		if  (isNaN(heightWall1) || heightWall1 == " " || heightWall1 == null || heightWall1 == "") 
		{
		msg1 = ":Mur 1 hauteur \n";
		msg2 = ":Wall 1 Height \n";
		pass = "no";
		}
		if  (isNaN(heightWall2) || heightWall2 == " " || heightWall2 == null || heightWall2 == "") 
		{
		msg1 = msg1 + ":Mur 2 hauteur \n";
		msg2 = msg2 + ":Wall 2 Height \n";
		pass = "no";
		}
		if  (isNaN(heightWall3) || heightWall3 == " " || heightWall3 == null || heightWall3 == "") 
		{
		msg1 = msg1 + ":Mur 3 hauteur \n";
		msg2 = msg2 + ":Wall 3 Height \n";
		pass = "no";
		}
		if  (isNaN(heightWall4) || heightWall4 == " " || heightWall4 == null || heightWall4 == "") 
		{
		msg1 = msg1 + ":Mur 4 hauteur \n";
		msg2 = msg2 + ":Wall 4 Height \n";
		pass = "no";
		}
		if  (isNaN(heightCeiling) || heightCeiling == " " || heightCeiling == null  || heightCeiling=="") 
		{
		msg1 = msg1 + ":Plafond  hauteur \n";
		msg2 = msg2 + ":Ceiling  Height \n";
		pass = "no";
		}
		if  (isNaN(WidthWall1) || WidthWall1 == " " || WidthWall1 == null || WidthWall1 == "")
		{
		msg1 = msg1 + ":Mur 1 longueur \n";
		msg2 = msg2 + ":Wall 1 Length \n";
		pass = "no";
		}
		if  (isNaN(WidthWall2) || WidthWall2 == " " || WidthWall2 == null || WidthWall2 == "") 
		{
		msg1 = msg1 + ":Mur 2 longueur \n";
		msg2 = msg2 + ":Wall 2 Length \n";
		pass = "no";
		}
		if  (isNaN(WidthWall3) || WidthWall3 == " " || WidthWall3 == null || WidthWall3 == "") 
		{
		msg1 = msg1 + ":Mur 3 longueur \n";
		msg2 = msg2 + ":Wall 3 Length \n";
		pass = "no";
		}
		if  (isNaN(WidthWall4) || WidthWall4 == " " || WidthWall4 == null  || WidthWall4 == "")
		{
		msg1 = msg1 + ":Mur 4 longueur \n";
		msg2 = msg2 + ":Wall 4 Length \n";
		pass = "no";
		}
		if  (isNaN(WidthCeiling) || WidthCeiling == " " || WidthCeiling == null || WidthCeiling == "") 
		{
		msg1 = msg1 + ":Plafond  largeur \n";
		msg2 = msg2 + ":Ceiling  width \n";
		pass = "no";
		}
		if  (isNaN(nondoor) || nondoor == " " || nondoor == null || nondoor == "") 
		{
		msg1 = msg1 + ":Dimension de la porte  \n";
		msg2 = msg2 + ":Door  \n";
		pass = "no";
		}if  (isNaN(nonWindow) || nonWindow == " " || nonWindow == null || nonWindow == "") 
		{
		msg1 = msg1 + ":Dimension de la fenêtre  \n";
		msg2 = msg2 + ":Window \n";
		pass = "no";
		}if  (isNaN(nonOther) || nonOther == " " || nonOther == null  || nonOther == "") 
		{
		msg1 = msg1 + ":Autre \n";
		msg2 = msg2 + ":Other \n";
		pass = "no";
		}
if (pass=="yes")
	{
	document.Len.submit();	
	}
else
	{
	if(lang==2){
		alert("Check your input in  \n" + msg2);
	}else{
		alert("Valider le(s) champ(s)  \n" + msg1);
	}
	return (false);
	}
}


function validateTapis(lang)
{
var pass = "yes"
var msg = ""
var Length
var width

Length = document.Len.Length.value
width = document.Len.width.value
PriceCarpet = document.Len.PriceCarpet.value

	if  (isNaN(Length) || Length == " " || Length == null || width == "") 
		{
		msg1 = "\n Longeur ";
		msg2 = "\n Length ";
		pass = "no";
		}
	if  (isNaN(width) || width == " " || width == null  || width == "") 
		{
		msg1 = msg1 + "\n Largeur";
		msg2 = msg2 + "\n width";
		pass = "no";
		}
		if  (isNaN(PriceCarpet) || PriceCarpet == " " || PriceCarpet == null  || PriceCarpet == "") 
		{
		msg1 = msg1 + " \n Prix";
		msg2 = msg2 + " \n PriceCarpet";
		pass = "no";
		}
if (pass=="yes")
	{
	document.Len.submit();	
	}
else
	{
	if(lang==2){	
		alert("Check your input in : " + msg2);
	}else{
		alert("Valider le(s) champ(s) : " + msg1);
	}
	return (false);
	}
}