// JavaScript Document

function blurLinks(){
	for(var i in document.links){
		document.links[i].onfocus = document.links[i].blur;
	}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function validateForm(kontakt) {
	if (kontakt.namn.value == "")
  	{
  	alert("Du måste fylla i ditt namn.")
  	kontakt.namn.focus()
	return false
	}
	else if (kontakt.adress.value == "")
  	{
  	alert("Du måste fylla i din adress.")
  	kontakt.adress.focus()
	return false
	}
	else if (kontakt.land.value == "")
  	{
  	alert("Du måste fylla i land.")
  	kontakt.land.focus()
	return false
	}
	else if (kontakt.tel.value == "" && kontakt.fax.value == "" && kontakt.epost.value == "")
  	{
  	alert("Du måste fylla i telefon, fax eller e-post.")
  	kontakt.epost.focus()
	return false
	}
	else
  	{
  	open_tack()
	return true
	}
	
}

function validateForm2(kontakt) {
	if (kontakt.namn.value == "")
  	{
  	alert("Your name must be filled in.")
  	kontakt.namn.focus()
	return false
	}
	else if (kontakt.adress.value == "")
  	{
  	alert("Your address must be filled in.")
  	kontakt.adress.focus()
	return false
	}
	else if (kontakt.land.value == "")
  	{
  	alert("Your country must be filled in.")
  	kontakt.land.focus()
	return false
	}
	else if (kontakt.tel.value == "" && kontakt.fax.value == "" && kontakt.epost.value == "")
  	{
  	alert("Your phone, fax or email must be filled in.")
  	kontakt.epost.focus()
	return false
	}
	else
  	{
  	open_tack()
	return true
	}
	
}

function open_tack(){
       window.open("../tack.html","","width=710,height=300,toolbar=no,resize=no,scrollbars=no");
}

function open_calc(){
       window.open("../page-calc.asp","","width=738,height=600,toolbar=no,resize=no,scrollbars=yes");
}

// ######################## - ¸ Copyright note - ###########################
//
//                  -- ¸ Copyright AULAB Webdesign 1998 ---
// This script is created exclusivly for Seibu Giken DST AB in Sweden,
//   by Lasse Bergquist, who also owns the Copyright for all JAVA-
//     script code in this document. The script itself, however -
//              belongs to Seibu Giken DST AB in Sweden!
//	You may NOT copy this Java Script Code, or part(s) of it,
//	 to be used elsewhere, with or without modifications, for 
//    any prposes, without permission in writing from both the Script 
//	  owner - Seibu Giken DST AB - AND the Script author -
//	  Lasse Bergquist, AULAB Webdesign, contact@aulab.com .

	
//---------------------------------------------------------------------
//############# VERSIONS:
//      As usual is the modification logg in the ascending order, wonder why.
//      V.4.2 An almost complete new version, the computer is now choosing dehumidifer self.
//
//
//		V 1.0: Original filename:	xl.htm
//		This version had a couple of serious bugs. It was finished
//		and delivered in a great hurry, and close to nonfunctional!

//		V 2.0: Original filename:	xl2.htm
//		This version replaced V 1.0 as the preliminary delivery to
//		the customer; Seibu Giken DST AB. 

//		V 2.0.1 Original filename	xl201.htm
//		The first revision of V 2.0 has an extended ¸ Copyright Note
//		and a version history description (this text).
//		Some cosmetic justifications have been made, and some of the 
//		functional code have been optimized. There is more work to 
//		be done, though!

//		V 2.0.2 Original filename	xl202.htm
//		The second revision of V 2.0 has been cleaned out from some 
//		minor scripting errors.
//		The improved formatting makes the interface more intuitive 
//		and the calculation results more readable.
//		The images from the original EXCEL document have been added, 
//		and a java button to view the copyright note above, has been 
//		inserted at the top and the bottom of the document.

// March 23:rd	V 2.0.3 Original filename	xl203.htm
// 1998		In the third revision of V 2.0, the calculation of "Needed" 
//		moisture content in the total airmix to the room" has been
//		updated by removing a rather embarrassing JavaScript error.
//		Somehow I (the author) missed to evaluate the individual 
//		values involved in the calculation, which results in treating 
//		the numbers as text (like: "2" + "2" = "22"). 


var debug = "off"; // I l„ge "on" kan man f”lja exekveringen och
//  var debug = "trace"; // I läge trace kan man följa vilka funktioner som anropas.
//                    hitta problemrader snabbt.
// ########################-Globala variabler-##########################
var B4 = 0;
var B10 = 0;
var B12 = 1013;
var B22 = 0;
var B24 = 15.84;
var B25 = 0;
var B7 = 0;
var B8 = 0;
var B9 = 0;
var B13 = 0;
var B27 = 0;
var B32 = 0;
var B40 = 0;
var B46 = 0;
var B49 = 0;
var B51 = 0;
var B63 = 0;
var B65 = 0;
var B68 = 0;
var B69 = 0;
var B75 = 0;
var B76 = 0;
var B77 = 0;
var B79 = 0;
var B81 = 0;
var B82 = 0;

//---------------

// F”rst best„mmer vi resultatets noggrannhet, 0 - 3 decimaler
var antaldecimaler = 2; 
// Om st”rre eller mindre noggrannhet ”nskas...
if (antaldecimaler == 0) {
  tol = 1}
  else if (antaldecimaler == 1) {
  tol = 10}
  else if (antaldecimaler == 2) {
  tol = 100}
  else if (antaldecimaler == 3) {
  tol = 1000};

// #####################################################################
// ####################-Globala Funktioner-#############################

//======================Skrivskydd i delresultst===================
function noinput(thisfield,display,moveto) {
  alert('\"'+thisfield+'\" is NOT an input box! \n This value will be set while calculating \"'+display+'\"');
  eval(moveto);
}

//=======================Skrivskydd i resultatf„lt==================

function outputfield(thisfield,display,moveto) {
  alert('\"'+thisfield+'\" is an OUTPUT FIELD, holding the result of this calculation! \n It will be used to calculate \"'+display+'\", below!');
  eval(moveto);
}

//========================Global procentvalidator==================

function perc_valid(field,max) {
  if (eval(field + '.value') == "") {
    eval(field).value = 0;
  }
//---------------

  if (debug == "last") {alert("3 Validation: only digit chars  --" + eval(field + '.value'));}
  var checkOK = "0123456789.";
  var checkStr = eval(field + '.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\" and \".\") in the \""+ field +"\" field.");
    eval(field).value = "";
    eval(field).focus();
    return (false);
  }
//------------------

  if (debug == "on") {alert("4 Validation:  Percentage range (0 - "+max+") --" + eval(field + '.value'));}
  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "0" && prsVal <= max)) {
    alert("Please enter a value greater than or equal to \"0\" and less than or equal to \""+max+"\"  in the \""+ field +"\" field.");
    eval(field).value = "";
    eval(field).focus();
    return (false);
  }
  return (true);
}


//================================================================


// #####################################################################
// #######################-Lokala Funktioner f”r-####################### 
// ########-"Desired room climate" och "Ambient design climate"-########
function calcb7val(theform) {
    if (debug == "trace") {alert("calcb7val");}
	if (validateB6B8(theform)) {
		calcb7(theform)
		return true}
	else
		return false
}
function calcb13val(theform) {
    if (debug == "trace") {alert("calcb13val");}
	if (calcb7val(theform)) {
		if (validateB12B13(theform)) {
			calcb13(theform)
			return true}
		else
			return false
		
	}
}
function calcb41val(theform) {
    if (debug == "trace") {alert("calcb41val");}
	if (calcb13val(theform)) {
		if (validateB21B23(theform)) {
			if (validateB25B31(theform)) {
				if (validateB33B39(theform)) {
					calcTotLoadVent(theform)
					return true}
				else
					return false
				
			}
		}
	}
}

function calcb47val(theform) {
    if (debug == "trace") {alert("calcb47val");}
	if (calcb41val(theform)) {
		if (validateB45B46(theform)) {
			calcTotLoadPeopl(theform)
			return true}
		else
			return false
		}
}
function calcb55val(theform) {
    if (debug == "trace") {alert("calcb55val");}
	if (calcb47val(theform)) {
		calcTotLoadWatSurfc(theform)
		return true}
	else
		return false
}
function calcb61val(theform) {
    if (debug == "trace") {alert("calcb61val");}
	if (calcb55val(theform)) {
		if (validateB58B60(theform)) {
//			alert('Nu kör vi');
			calcProductDying(theform)
			return true}
		else
			return false
		}
}
function calcb7(theform) {
// Om ber„kningsbara v„rden...
//  Vi l„ser anv„ndarinmatningen 
    B4 = eval(theform + ".Temperature1.value");
    var tmp2 = eval(theform + ".Relative_humidity1.value");
//  tilldela glob.var. v„rde...
    B8 = eval(theform + ".Atmospheric_pressure1.value");
    if ((eval(theform + ".Atmospheric_pressure2.value") < eval(theform + ".Atmospheric_pressure1.value")) || (eval(theform + ".Atmospheric_pressure2.value") > eval(theform + ".Atmospheric_pressure1.value"))) {
      eval(theform + ".Atmospheric_pressure2").value = B8;
    }
    eval(theform + ".C14").value = B8;
//  Med de inl„sta v„rdena utf”r vi ber„kningen och tilldelar resultatcellen dess v„rde.
    B9 = (622/(eval(theform + '.Atmospheric_pressure1.value')/((Math.exp(12.03-(4025/(eval(B4)+235))))*10*eval(tmp2))-1));
    eval(theform + ".Moisture_content1").value =  Math.round( 10*eval(B9) )/10 ;
//  eval(theform + ".Moisture_content1").value =  Math.round(eval(tol)*(622/(eval(theform + '.Atmospheric_pressure1.value')/((Math.exp(12.03-(4025/(eval(B4)+235))))*10*eval(tmp2))-1)))/eval(tol) ;
//  622/(B6/EXP(12,03-4025/(B4+235))/10/B5-1)
    eval(theform + ".Temperature2.focus()");
    return (true);
}

//================================================================

function calcb13(theform) {
//alert("calcb13")
//Ber„kna Moisture Content s† att B12 tilldelas sitt v„rde...
//  Om ber„kningsbara v„rden...
//    Vi l„ser anv„ndarinmatningen 
      B10 = eval(theform + ".Temperature2.value");
      C12 = B10 - 5		//S
      eval(theform + ".C12").value = C12; //S
      eval(theform + ".C13").value = eval(theform + ".Relative_humidity2").value; //S
      var tmp2 = eval(theform + ".Relative_humidity2.value");
      var tmp3 = eval(theform + ".C13.value"); //S
//    Med de inl„sta v„rdena utf”r vi ber„kningen och tilldelar resultatcellen dess v„rde.
      B13 = (622/(eval(theform + '.Atmospheric_pressure2.value')/((Math.exp(12.03-(4025/(eval(B10)+235))))*10*eval(tmp2))-1));
      C13 = (622/(eval(theform + '.C14.value')/((Math.exp(12.03-(4025/(eval(C12)+235))))*10*eval(tmp3))-1)); //S
      eval(theform + ".Moisture_content2").value =  Math.round( eval(tol)* eval(B13) )/eval(tol) ;
      eval(theform + ".C15").value =  Math.round( eval(tol)* eval(C13) )/eval(tol) ; //S
//    eval(theform + ".Moisture_content2").value =  Math.round(eval(tol)*(622/(eval(theform + '.Atmospheric_pressure2.value')/((Math.exp(12.03-(4025/(eval(B10)+235))))*10*eval(tmp2))-1)))/eval(tol) ;
//    622/(B12/EXP(12,03-4025/(B10+235))/10/B11-1)
      eval(theform + ".Room_length.focus()");
      return (true);
}

function calcc13(theform) {
//=622/(C14/EXP(12,03-4025/(C12+235))/10/C13-1)
// if (ValidatorName(theform + ".C12","Temperature") && ValidatorName(theform + ".C13","Relative humidity") && ValidatorName(theform + ".C14","Atmospheric pressure")) {
	if (validateC12C13(theform)) {
	C12 = eval(theform + ".C12.value");      
      var tmp3 = eval(theform + ".C13.value"); //S
	C14 = eval(theform + ".C14.value");      
//    C15 = eval(622/(eval(C14)/Math.exp(12.03-4025/(eval(C12)+235))/10/eval(C13)-1)); //S
    C13 = (622/(eval(theform + '.C14.value')/((Math.exp(12.03-(4025/(eval(C12)+235))))*10*eval(tmp3))-1)); //S
    eval(theform + ".C15").value =  Math.round( eval(tol)* eval(C13) )/eval(tol) ; //S
	}
	return (true)
}

// #####################################################################
// #######################-Lokala Funktioner f”r-#######################
// ######################-resten av formul„ret...-######################


function ValidatorNameMinMax (field,fieldname,min,max,decimals) {

  var checkOK = "0123456789-.";
  var checkStr = eval(field + '.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\"), decimal sign (period \".\") and minus sign (\"-\") in the \""+ fieldname +"\" field.");
    eval(field).value = "";
    eval(field).focus();
    return (false);
  }
  
  if (checkStr > max){
    alert("Please enter value less or equal than " + max + " for \""+ fieldname +"\" field.");
    eval(field).value = "";
    eval(field).focus();
    return (false);
  }
  
  if (checkStr < min){
    alert("Please enter value larger or equal than " + min + " for \""+ fieldname +"\" field.");
    eval(field).value = "";
    eval(field).focus();
    return (false);
  }
  return (true);
}
  	
function ValidatorName (field,fieldname) {
  if (debug == "on") {
    var str1 = (field + ".value");
    alert("1b " + str1 + "=" + eval(str1));
  }
//----------------

  if (debug == "on") {alert("2a Validation: empty field  --" + eval(field + '.value'));}
  if (eval(field + '.value') == "") {
    alert("Please enter a value for the \""+ fieldname +"\" field.");
    eval(field).focus();
    return (false);
  }
//--------------

// if (debug == "on") {alert("2b Validation: too many characters  --" + eval(field + '.value'));}
// if (eval(field + '.length') > 6) {
//   alert("Please enter at most 6 characters in the \""+ field +"\" field.");
//   eval(field).focus();
//   return (false);
// }
//---------------

  if (debug == "on") {alert("3 Validation: only digit chars  --" + eval(field + '.value'));}
  var checkOK = "0123456789-.";
  var checkStr = eval(field + '.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\"), decimal sign (period \".\") and minus sign (\"-\") in the \""+ fieldname +"\" field.");
    eval(field).value = "";
    eval(field).focus();
    return (false);
  }
//------------------

  if (debug == "on") {alert("4 Validation:  range  --" + eval(field + '.value'));}
  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1" && prsVal <= "100000")) {
    alert("Please enter a value greater than or equal to \"1\" and less than or equal to \"100000\" in the \""+ fieldname +"\" field.");
    eval(field).value = "";
    eval(field).focus();
    return (false);
  }
  return (true);
}


//================================================================




function G_val(theform) {
  if (debug == "on") {alert("Validation of G: empty field  --" + eval(theform + '.G.value'));}
//----------------
  if (eval(theform + '.G.value') == "") {
    alert("Please enter a value for the \"Mechanical ventilation\" field.");
    eval(theform).G.focus();
    return (false);
  }
//---------------

  if (debug == "on") {alert("Validation of G: only digit chars  --" + eval(theform + '.G.value'));}
  var checkOK = "0123456789.";
  var checkStr = eval(theform + '.G.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\" and \".\") in the \"Mechanical ventilation\" field.");
    eval(theform).G.value = "";
    eval(theform).G.focus();
    return (false);
  }
//------------------

  if (debug == "on") {alert("4 Validation:  G range (0 - 100000) --" + eval(theform + '.G.value'));}
  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "0" && prsVal <= "100000")) {
    alert("Please enter a value greater than or equal to \"0\" and less than or equal to \"100000\" in the \"Mechanical ventilation\" field.");
    eval(theform).G.value = "";
    eval(theform).G.focus();
    return (false);
  }
  return (true);
}

//================================================================

function calcTotLoadVent(theform) {
// 1. Room_volume(B24)=B21*B22*B23
// 2. =(0,075+$B$25/7*(1,08-0,075))*B33/9*(3,76+$B$26)/7,76*(($B$21+$B$22)*$B$23*2+$B$21*$B$22)+0,25*$B$27*$B$28*3600*B34/60+B35*$B$29*$B$30*$B$31/2
/*    if (ValidatorName(theform + ".Room_length","Room length") && ValidatorName(theform + ".Room_width","Room width") && ValidatorName(theform + ".Room_height","Room height")) {
	  if (debug == "on") {alert("Set variables for Room Volume.");}
	  if (!ValidatorName(theform + ".B25","Tightness of building")) {return (false);}
	  if (!ValidatorName(theform + ".B26","Surroundings")) {return (false);}
	  if (!ValidatorName(theform + ".B27","Door without air lock vestibule,height")) {return (false);}
	  if (!ValidatorName(theform + ".B28","Door without air lock vestibule,width")) {return (false);}
	  if (!ValidatorName(theform + ".B29","Air lock vestibule, length")) {return (false);}
	  if (!ValidatorName(theform + ".B30","Air lock vestibule, width")) {return (false);}
	  if (!ValidatorName(theform + ".B31","Air lock vestibule, height")) {return (false);}
	  if (!ValidatorName(theform + ".B33","Wind speed")) {return (false);}
	  if (!ValidatorName(theform + ".B34","Door without air lock, opened per hour")) {return (false);}
	  if (!ValidatorName(theform + ".B35","Air lock vestibule, passages per hour")) {return (false);}
	  if (!ValidatorName(theform + ".B37","Open holes")) {return (false);}
	  if (!ValidatorName(theform + ".B39","Mechanical ventilation")) {return (false);}*/
	  
	var langdb19 = eval(theform + ".Room_length.value");
	var viddb20 = eval(theform + ".Room_width.value");
	var hojdb21 = eval(theform + ".Room_height.value");
	B24 = eval("langdb19*viddb20*hojdb21");
      
//    Set Room volume value
	eval(theform).Room_volume.value = Math.round( eval(tol)*B24 )/eval(tol);
	B9  = getB9(theform);
	B15 = getB15(theform);
	C15 = eval(theform + ".C15.value");
	B21 = eval(theform + ".Room_length.value");
	B22 = eval(theform + ".Room_width.value");
	B23 = eval(theform + ".Room_height.value");
	B25 = eval(theform + ".B25.value");
	B26 = eval(theform + ".B26.value");
	B27 = eval(theform + ".B27.value");
	B28 = eval(theform + ".B28.value");
	B29 = eval(theform + ".B29.value");
	B30 = eval(theform + ".B30.value");
	B31 = eval(theform + ".B31.value");
	B33 = eval(theform + ".B33.value");
	B34 = eval(theform + ".B34.value");
	B35 = eval(theform + ".B35.value");
	B39 = eval(theform + ".B39.value");
	eval(theform).C33.value = B33/2;
	eval(theform).C34.value = B34/2;
	eval(theform).C35.value = B35/2;
	C33 = eval(theform + ".C33.value");
	C34 = eval(theform + ".C34.value");
	C35 = eval(theform + ".C35.value");
      
	B36 = (0.075+eval(B25)/7*(1.08-0.075))*eval(B33)/9*(3.76+eval(B26))/7.76*((eval(B21)+eval(B22))*eval(B23)*2+eval(B21)*eval(B22))+0.25*eval(B27)*eval(B28)*3600*eval(B34)/60+eval(B35)*eval(B29)*eval(B30)*eval(B31)/2
//                            =(0,075+B25/7*(1,08-0,075))*B33/9*(3,76+B26)/7,76*((B21+B22)*B23*2+B21*B22)+0,25*B27*B28*3600*B34/60+B35*B29*B30*B31/2

	eval(theform).C36.value = Math.round((0.075+eval(B25)/7*(1.08-0.075))*eval(C33)/9*(3.76+eval(B26))/7.76*((eval(B21)+eval(B22))*eval(B23)*2+eval(B21)*eval(B22))+0.25*eval(B27)*eval(B28)*3600*eval(C34)/60+eval(C35)*eval(B29)*eval(B30)*eval(B31)/2)
	eval(theform).C37.value = eval(theform).B37.value;
	B38 = Math.round(eval(theform).B37.value*0.8*3600);
	eval(theform).C38.value = Math.round(eval(theform).C37.value*0.8*3600);
	eval(theform).C39.value = eval(theform).B39.value;
    eval(theform).B36.value = Math.round(B36*1)/1;
    eval(theform).B38.value = B38;
    C36 = eval(theform + ".C36.value");
    C38 = eval(theform + ".C38.value");
    C39 = eval(theform + ".C39.value");
	B40 = eval(B39)+eval(B38)+eval(B36);
    eval(theform).B40.value = Math.round(B40*1)/1;
	eval(theform).C40.value = eval(C39)+eval(C38)+eval(C36);
    C40 = eval(theform + ".C40.value");
//  val(theform).C40.value = Math.round(eval(theform).C39.value+eval(theform).C38.value+eval(theform).C36.value);
	
	
	eval(theform).Percentage_leakage.value = Math.round((eval(theform).B40.value/eval(B24)*100));
	eval(theform).Percentage_leakage2.value = Math.round((eval(theform).C40.value/eval(B24)*100));

	BXX = (eval(B40)*1.2*(eval(B15)-eval(B9))/1000);
	eval(theform).Total_ventilation.value = Math.round(eval(tol)*BXX)/eval(tol);
// eval(theform).Total_ventilation.value=Math.round(eval(theform).B40.value*1.2*(eval(B15)-eval(B9)))/1000;
	BXX = (eval(C40)*1.2*(eval(C15)-eval(B9))/1000);
	eval(theform).Total_ventilation2.value=Math.round(eval(tol)*BXX)/eval(tol);
	eval(theform).B45.focus();
	return (true);
}

function calcTotLoadVentC42(theform) {
// 1. Room_volume(B24)=B21*B22*B23
// 2. =(0,075+$B$25/7*(1,08-0,075))*B33/9*(3,76+$B$26)/7,76*(($B$21+$B$22)*$B$23*2+$B$21*$B$22)+0,25*$B$27*$B$28*3600*B34/60+B35*$B$29*$B$30*$B$31/2
   if (calcb13val(theform)  &&  validateB21B23(theform) &&  validateB25B31(theform)) {
/*	  if (!ValidatorName(theform + ".B25","Tightness of building")) {return (false);}
	  if (!ValidatorName(theform + ".B26","Surroundings")) {return (false);}
	  if (!ValidatorName(theform + ".B27","Door without air lock vestibule,height")) {return (false);}
	  if (!ValidatorName(theform + ".B28","Door without air lock vestibule,width")) {return (false);}
	  if (!ValidatorName(theform + ".B29","Air lock vestibule, length")) {return (false);}
	  if (!ValidatorName(theform + ".B30","Air lock vestibule, width")) {return (false);}
	  if (!ValidatorName(theform + ".B31","Air lock vestibule, height")) {return (false);} */
	  if (!ValidatorName(theform + ".C33","Wind speed")) {return (false);}
//	  if (!ValidatorName(theform + ".C34","Door without air lock, opened per hour")) {return (false);}
//	  if (!ValidatorName(theform + ".C35","Air lock vestibule, passages per hour")) {return (false);}
	  if (!ValidatorName(theform + ".C37","Open holes")) {return (false);}
	  if (!ValidatorName(theform + ".C39","Mechanical ventilation")) {return (false);}
	  
		var langdb19 = eval(theform + ".Room_length.value");
		var viddb20 = eval(theform + ".Room_width.value");
		var hojdb21 = eval(theform + ".Room_height.value");
		B24 = eval("langdb19*viddb20*hojdb21");
      
//    Set Room volume value
		eval(theform).Room_volume.value = Math.round( eval(tol)*B24 )/eval(tol);
		B9  = eval(theform + ".Moisture_content1.value");
		C15 = eval(theform + ".C15.value");
		B21 = eval(theform + ".Room_length.value");
		B22 = eval(theform + ".Room_width.value");
		B23 = eval(theform + ".Room_height.value");
		B25 = eval(theform + ".B25.value");
		B26 = eval(theform + ".B26.value");
		B27 = eval(theform + ".B27.value");
		B28 = eval(theform + ".B28.value");
		B29 = eval(theform + ".B29.value");
		B30 = eval(theform + ".B30.value");
		B31 = eval(theform + ".B31.value");
	      
		C33 = eval(theform + ".C33.value");
		C34 = eval(theform + ".C34.value");
		C35 = eval(theform + ".C35.value");
      
		eval(theform).C36.value = Math.round((0.075+eval(B25)/7*(1.08-0.075))*eval(C33)/9*(3.76+eval(B26))/7.76*((eval(B21)+eval(B22))*eval(B23)*2+eval(B21)*eval(B22))+0.25*eval(B27)*eval(B28)*3600*eval(C34)/60+eval(C35)*eval(B29)*eval(B30)*eval(B31)/2)
		eval(theform).C38.value = Math.round(eval(theform).C37.value*0.8*3600);
		C36 = eval(theform + ".C36.value");
		C38 = eval(theform + ".C38.value");
		C39 = eval(theform + ".C39.value");
		eval(theform).C40.value = eval(C39)+eval(C38)+eval(C36);
		C40 = eval(theform + ".C40.value");
	
		eval(theform).Percentage_leakage2.value = Math.round((eval(theform).C40.value/eval(B24)*100));

//	eval(theform).Total_ventilation2.value=Math.round(eval(theform).C40.value*1.2*(eval(C15)-eval(B9)))/1000;
		BXX = (eval(C40)*1.2*(eval(C15)-eval(B9))/1000);
		eval(theform).Total_ventilation2.value=Math.round(eval(tol)*BXX)/eval(tol);

		eval(theform).B45.focus();
		return (true);
	}
	else return (false);
}

function calcProductDying(theform) {
	B58 = eval(theform + ".Total_weight_of_products.value");
	B59 = eval(theform + ".Percentage_of_moisture_at_start.value");
	B60 = eval(theform + ".Percentage_dried_in_one_hour.value");
	B61 = eval(B59)*eval(B58)*eval(B60) / 10000;
	eval(theform).B61.value=Math.round(eval(tol)*B61)/eval(tol);

    eval(theform).C58.value = B58;
    eval(theform).C59.value = B59;
    eval(theform).C60.value = B60;
	eval(theform).C61.value=Math.round(eval(tol)*B61)/eval(tol);
    eval(theform).Total_load_from_other_sources.focus();
	return (true);
}
	
function calcProductDyingC(theform) {
	if (!ValidatorName(theform + ".C58","Total_weight_of_products")) {return (false);}
	if (!ValidatorName(theform + ".C59","Percentage_of_moisture_at_start")) {return (false);}
	if (!ValidatorName(theform + ".C60","Percentage_dried_in_one_hour")) {return (false);}
	C58 = eval(theform + ".C58.value");
	C59 = eval(theform + ".C59.value");
	C60 = eval(theform + ".C60.value");
	C61 = eval(C59)*eval(C58)*eval(C60)
	eval(theform).C61.value=Math.round(eval(tol)*C61)/eval(tol);
	return (true);
}

//================================================================
function moist_load_fr_each(theform) {
//----------------
  if (eval(theform + '.B46.value') == "") {
    alert("Please enter a value for the \"Moisture load from each\" field.");
    eval(theform).B46.focus();
    return (false);
  }
//----------------

  if (eval(theform + '.B45.value') == "") {
    alert("Please enter a value for the \"Number_of_people\" field.");
    eval(theform).B45.focus();
    return (false);
  }
//---------------

  var checkOK = "0123456789.";
  var checkStr = eval(theform + '.B46.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\") and decimal sign (period \".\") in the \"Moisture load from each\" field.");
    eval(theform).B46.value = "";
    eval(theform).B46.focus();
    return (false);
  }
//------------------

  if (debug == "on") {alert(" Validation:  \"Moisture load from each\" range (0.05 - 0.3) --" + eval(theform + '.Moisture_load_from_each.value'));}
  var bignumint = 100*eval(allNum);
  if (debug == "on") {alert("allNum is: "+ allNum+". \n bignumint is: "+bignumint+". \n ");}
  var chkVal = bignumint;
  var prsVal = parseInt(bignumint);
  if (chkVal != "" && !(prsVal >= "5" && prsVal <= "30")) {
    alert("Please enter a value greater than or equal to \"0.05\" and less than or equal to \"0.3\" in the \"Moisture load from each\" field.");
    eval(theform).B46.value = "";
    eval(theform).B46.focus();
    return (false);
  }
//---------------

  if (debug == "on") {alert("Validation of \"Number of people\": only digit chars  --" + eval(theform + '.Number_of_people.value'));}
  var checkOK = "0123456789";
  var checkStr = eval(theform + '.B45.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\") in the \"Number of people\" field.");
    eval(theform).B45.value = "";
    eval(theform).B45.focus();
    return (false);
  }
//------------------

  if (debug == "on") {alert("4 Validation:  \"Number of people\" range (0 - 40000) --" + eval(theform + '.Number_of_people.value'));}
  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "0" && prsVal <= "40000")) {
    alert("Please enter a value greater than or equal to \"0\" and less than or equal to \"40 000\" in the \"Number_of_people\" field.");
    eval(theform).B45.value = "";
    eval(theform).B45.focus();
    return (false);
  }
  return (true);
}
function moist_load_fr_eachC(theform) {
//----------------
  if (eval(theform + '.C46.value') == "") {
    alert("Please enter a value for the \"Moisture load from each\" field.");
    eval(theform).C46.focus();
    return (false);
  }
//----------------

  if (eval(theform + '.C45.value') == "") {
    alert("Please enter a value for the \"Number_of_people\" field.");
    eval(theform).C45.focus();
    return (false);
  }
//---------------

  var checkOK = "0123456789.";
  var checkStr = eval(theform + '.C46.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\") and decimal sign (period \".\") in the \"Moisture load from each\" field.");
    eval(theform).C46.value = "";
    eval(theform).C46.focus();
    return (false);
  }
//------------------

  if (debug == "on") {alert(" Validation:  \"Moisture load from each\" range (0.05 - 0.3) --" + eval(theform + '.Moisture_load_from_each.value'));}
  var bignumint = 100*eval(allNum);
  if (debug == "on") {alert("allNum is: "+ allNum+". \n bignumint is: "+bignumint+". \n ");}
  var chkVal = bignumint;
  var prsVal = parseInt(bignumint);
  if (chkVal != "" && !(prsVal >= "5" && prsVal <= "30")) {
    alert("Please enter a value greater than or equal to \"0.05\" and less than or equal to \"0.3\" in the \"Moisture load from each\" field.");
    eval(theform).C46.value = "";
    eval(theform).C46.focus();
    return (false);
  }
//---------------

  if (debug == "on") {alert("Validation of \"Number of people\": only digit chars, decimals allowed  --" + eval(theform + '.Number_of_people.value'));}
  var checkOK = "0123456789.";
  var checkStr = eval(theform + '.C45.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\") in the \"Number of people\" field.");
    eval(theform).C45.value = "";
    eval(theform).C45.focus();
    return (false);
  }
//------------------

  if (debug == "on") {alert("4 Validation:  \"Number of people\" range (0 - 40000) --" + eval(theform + '.Number_of_people.value'));}
  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "0" && prsVal <= "40000")) {
    alert("Please enter a value greater than or equal to \"0\" and less than or equal to \"40 000\" in the \"Number_of_people\" field.");
    eval(theform).C45.value = "";
    eval(theform).C45.focus();
    return (false);
  }
  return (true);
}

//================================================================

function pool_validator(theform) {
	return (true);
  if (debug == "on") {alert("Validation: empty field  --" + eval(theform + '.Pool_length.value'));}
//----------------
  if (eval(theform + '.Pool_length.value') == "") {
    alert("Please enter a value for the \"Pool length\" field.");
    eval(theform).Pool_length.focus();
    return (false);
  }
//----------------

  if (debug == "on") {alert("Validation: empty field  --" + eval(theform + '.Pool_width.value'));}
  if (eval(theform + '.Pool_width.value') == "") {
    alert("Please enter a value for the \"Pool width\" field.");
    eval(theform).Pool_width.focus();
    return (false);
  }
//---------------

  if (debug == "on") {alert("Validation: only digit chars  --" + eval(theform + '.Pool_length.value'));}
  var checkOK = "0123456789.";
  var checkStr = eval(theform + '.Pool_width.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\") and decimal sign (period \".\") in the \"Pool length\" field.");
    eval(theform).Pool_length.value = "";
    eval(theform).Pool_length.focus();
    return (false);
  }
//---------------

  if (debug == "on") {alert("Validation: only digit chars  --" + eval(theform + '.Pool_width.value'));}
  var checkOK = "0123456789.";
  var checkStr = eval(theform + '.Pool_width.value');
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    allNum += ch; 
  }
  if (!allValid) {
    alert("Please enter only digit characters (\"0\" - \"9\") and decimal sign (period \".\") in the \"Pool width\" field.");
    eval(theform).Pool_width.value = "";
    eval(theform).Pool_width.focus();
    return (false);
  }
  return (true);
}


//================================================================

function calcTotLoadPeopl(theform) {
	B45 = eval(theform + ".B45.value");
	B46 = eval(theform + ".B46.value");
	C45 = eval(theform + ".C45.value");
	C46 = eval(theform + ".C46.value");
	B32 = eval(B45) * eval(B46);
	C32 = eval(C45) * eval(C46);
	eval(theform).B47.value = Math.round( eval(tol)*B32 )/eval(tol) ;
	eval(theform).C47.value = Math.round( eval(tol)*C32 )/eval(tol) ;
    eval(theform).B50.focus();
	return (true);
}
function calcTotLoadPeoplC47(theform) {
	if (moist_load_fr_eachC(theform)) {
		C45 = eval(theform + ".C45.value");
		C46 = eval(theform + ".C46.value");
		C32 = eval(C45) * eval(C46);
		eval(theform).C47.value = Math.round( eval(tol)*C32 )/eval(tol) ;
		return (true);
      }
}

//================================================================

function calcTotLoadWatSurfc(theform) {
	  if (eval(theform + '.B53.value') == ""){
		eval(theform).B53.value = eval(theform + ".Temperature1.value");
	  }
	
//    B8 = eval(theform + ".Atmospheric_pressure2.value");
//    B9 = eval(theform + ".Moisture_content1.value");
      B50 = eval(theform + ".B50.value");
      B51 = eval(theform + ".B51.value");
      B52 = eval(B50) * eval(B51);
      eval(theform).B52.value = eval(B52);
      B53 = eval(theform + ".B53.value");
      B54 = eval(theform + ".B54.value");
      B55 = eval(B54)*eval(B52)*(622/(eval(B8)/Math.exp(12.03-4025/(eval(B53)+235))/1000-1)-eval(B9))/1000;
	  eval(theform).B55.value = Math.round(eval(tol)*B55)/eval(tol);

      C50 = eval(theform + ".B50.value");
      C51 = eval(theform + ".B51.value");
      C52 = eval(C50) * eval(C51);
      C53 = eval(theform + ".B53.value");
      C54 = eval(theform + ".B54.value");
      eval(theform).C50.value = eval(C50);
      eval(theform).C51.value = eval(C51);
      eval(theform).C52.value = eval(C52);
      eval(theform).C53.value = eval(C53);
      eval(theform).C54.value = eval(C54);
	  C55 = Math.round(eval(C54)*eval(C52)*(622/(eval(B8)/Math.exp(12.03-4025/(eval(C53)+235))/1000-1)-eval(B9)))/1000;
	  eval(theform).C55.value = Math.round(eval(tol)*C55)/eval(tol);
      eval(theform).Total_weight_of_products.focus();

      return (true);
}
function calcTotLoadWatSurfcC(theform) {
  if (calcTotLoadPeopl(theform)) {
    if (pool_validator(theform)) {
      B8 = eval(theform + ".Atmospheric_pressure2.value");
	  B9 = eval(theform + ".Moisture_content1.value");
 	  if (!ValidatorName(theform + ".C50","Pool length")) {return (false);}
	  if (!ValidatorName(theform + ".C51","Pool width")) {return (false);}
	  if (!ValidatorName(theform + ".C54","Vaporization coefficient")) {return (false);}

      C50 = eval(theform + ".C50.value");
      C51 = eval(theform + ".C51.value");
      C52 = eval(C50) * eval(C51);
      C53 = eval(theform + ".C53.value");
      C54 = eval(theform + ".C54.value");
      eval(theform).C50.value = eval(C50);
      eval(theform).C51.value = eval(C51);
      eval(theform).C52.value = eval(C52);
      eval(theform).C53.value = eval(C53);
      eval(theform).C54.value = eval(C54);
//	  eval(theform).C55.value = Math.round(eval(C54)*eval(C52)*(622/(eval(B8)/Math.exp(12.03-4025/(eval(C53)+235))/1000-1)-eval(B9)))/1000;
	  C55 = Math.round(eval(C54)*eval(C52)*(622/(eval(B8)/Math.exp(12.03-4025/(eval(C53)+235))/1000-1)-eval(B9)))/1000;
	  eval(theform).C55.value = Math.round(eval(tol)*C55)/eval(tol);

      return (true);
    }
    else return (false);
  }
  else return (false);
}
//================================================================
function TotMoist_validator(theform,tw,stperc,drperc) {
  tw = "."+tw;
  stperc = "."+stperc;
  drperc = "."+drperc;
//----------------
  if (debug == "on") {alert("Validation: empty fields or non digits:  -- \n"
   + eval(theform+tw) + eval(theform+stperc) + eval(theform+drperc));}
//----------------
  if (eval(theform + tw + '.value') == "") {
    alert("Please enter a value for the \"Total weight of products\" field.");
    eval(theform+tw).focus();
    return (false);
  }
//----------------
  if (eval(theform + stperc + '.value') == "") {
    eval(theform+stperc).value = 0;
  }
//----------------
  if (eval(theform + drperc + '.value') == "") {
    eval(theform+drperc).value = 0;
  }
//----------------

  for (k = 0;  k < 3;  k++) {
    if (k == 0) {tst = tw } else
    if (k == 1) {tst = stperc } else
    if (k == 2) {tst = drperc } ;
    var checkOK = "0123456789.";
    var checkStr = eval(theform + tst +'.value');
    var allValid = true;
    var decPoints = 0;
    var allNum = "";
    for (i = 0;  i < checkStr.length;  i++) {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
          break;
      if (j == checkOK.length) {
        allValid = false;
        break;
      }
      allNum += ch; 
    }
    if (!allValid) {
      alert("Please enter only digit characters (\"0\" - \"9\") and decimal sign (period \".\") in this field.");
      eval(theform+tst).value = "";
      eval(theform + tst).focus();
      return (false);
      break;
    }
  }
  return (true);
}
//---------------

function validateB6B8(theform) {
// B6  temperature 
	if (ValidatorNameMinMax(theform + ".Temperature1","Temperature",-50,60,0))
// B7  Relative_humidity		
	    if (ValidatorNameMinMax(theform + ".Relative_humidity1","Relative humidity",0,100,0))
// B8  Atmospheric_pressure1	
		    if (ValidatorNameMinMax(theform + ".Atmospheric_pressure1","Atmospheric pressure",950,1100,0))
				return true
			else
				return false
		else
			return false
	else
		return false
}

function validateB12B13(theform) {
// B12 Temperature2
    if (ValidatorNameMinMax(theform + ".Temperature2","Temperature",0,50,0))
// B13 Relative_humidity2
	    if (ValidatorNameMinMax(theform + ".Relative_humidity2","Relative humidity",0,100,0))
			return true
		else
			return false
	else
	    return false
}
function validateC12C13(theform) {
// B12 Temperature2
    if (ValidatorNameMinMax(theform + ".C12","Temperature",0,50,0))
// B13 Relative_humidity2
	    if (ValidatorNameMinMax(theform + ".C13","Relative humidity",0,100,0))
			return true
		else
			return false
	else
	    return false
}

function validateB21B23(theform) {
// B21 Room_length				    
    if (ValidatorNameMinMax(theform + ".Room_length","Room length",0,1000,0))
// B22 Room_width					    
	    if (ValidatorNameMinMax(theform + ".Room_width","Room width",0,1000,0))
// B23 Room_height
		    if (ValidatorNameMinMax(theform + ".Room_height","Room height",0,100,0))
				return true
			else
				return false
		else
			return false
	else
   		return false
}

function validateB25B31(theform) {
// B25 Tightness of building
    if (ValidatorNameMinMax(theform + ".B25","Tightness of building",1,7,0))
// B26 Surroundings  
		if (ValidatorNameMinMax(theform + ".B26","Surroundings",1,4,0))
// B27 Door without air lock vestibule, height
			if (ValidatorNameMinMax(theform + ".B27","Door without air lock vestibule, height",0,50,0))
// B28 Door without air lock vestibule, width
				if (ValidatorNameMinMax(theform + ".B28","Door without air lock vestibule, width",0,200,0))
// B29 Air lock vestibule, length
					if (ValidatorNameMinMax(theform + ".B29","Air lock vestibule, length",0,200,0))
// B30 Air lock vestibule, width
						if (ValidatorNameMinMax(theform + ".B30","Air lock vestibule, width",0,200,0))
// B31 Air lock vestibule, height
							if (ValidatorNameMinMax(theform + ".B31","Air lock vestibule, height",0,200,0))
								return true
							else
								return false
						else
							return false
					else
						return false
				else
					return false
			else
				return false
		else
			return false
	else
		return false
}

function validateB33B39(theform) {
// B33 Wind speed
    if (ValidatorNameMinMax(theform + ".B33","Wind speed",0,20,0))
// B34 Door without air lock, opened per hour 
		if (ValidatorNameMinMax(theform + ".B34","Door without air lock, opened per hour",0,60,0))
// B35 Air lock vestibule, passages per hour
			if (ValidatorNameMinMax(theform + ".B35","Air lock vestibule, passages per hour",0,1000,0))
// B37 Open holes 
				if (ValidatorNameMinMax(theform + ".B37","Open holes",0,100,0))
// B39 Mechanical ventilation 
					if (ValidatorNameMinMax(theform + ".B39","Mechanical ventilation",0,1000000,0))
						return true
					else
						return false
				else
					return false
			else
				return false
		else
			return false
	else
		return false
}

function validateB45B46(theform) {
// B45 Number of people
    if (ValidatorNameMinMax(theform + ".B45","Number of people",0,100000,0))
// B46 Moisture load from each
		if (ValidatorNameMinMax(theform + ".B46","Moisture load from each",0,0.5,1))
			return true
		else
			return false
	else
		return false
}								

function validateB50B54(theform) {
// B50 Wind speed
    if (ValidatorNameMinMax(theform + ".B50","Wind speed",0,500,0))
// B51 Door without air lock, opened per hour 
		if (ValidatorNameMinMax(theform + ".B51","Door without air lock, opened per hour",0,500,0))
// B53 Air lock vestibule, passages per hour
			if (ValidatorNameMinMax(theform + ".B53","Air lock vestibule, passages per hour",0,99,0))
// B54 Open holes 
				if (ValidatorNameMinMax(theform + ".B54","Open holes",5,20,0))
					return true
				else
					return false
			else
				return false
		else
			return false
	else
		return false
}

function validateB58B60(theform) {
// B58 Total weight of products
    if (ValidatorNameMinMax(theform + ".Total_weight_of_products","Total weight of products",0,1000000,0))
// B59 Percentage of moisture at start
		if (ValidatorNameMinMax(theform + ".Percentage_of_moisture_at_start","Percentage of moisture at start",0,100,0))
// B60 Percentage dried in 1 hour
			if (ValidatorNameMinMax(theform + ".Percentage_dried_in_one_hour","Percentage dried in 1 hour",0,100,0))
				return true
			else
				return false
		else
			return false
	else
		return false
}

function validateB64(theform) {
// B64 Total load from other sources 
	if (ValidatorNameMinMax(theform + ".Total_load_from_other_sources","Total load from other sources",0,1000,0))
		return true
	else
		return false
}

function validateAll(theform){
	if (validateB6B8(theform))
		if (validateB12B13(theform))
			if (validateB21B23(theform))
				if (validateB25B31(theform))
					if (validateB33B39(theform))
						if (validateB50B54(theform))
							if (validateB58B60(theform))
								if (validateB64(theform))
									return true
								else
									return false
							else
								return false
						else
							return false
					else
						return false
				else
					return false
			else
				return false
		else
			return false
	else
		return false
}			

function calcTotMoistLoad(theform) {
//=B64+B61+B55+B47+B42
	if (calcb61val(theform)) {
		validateB64(theform) 
		
//		calcb7(theform);
//		calcb13(theform);
//		calcTotLoadVent(theform);
//		calcTotLoadPeopl(theform);
//		calcTotLoadWatSurfc(theform);
//		calcProductDying(theform);
		B42 = eval(theform + ".Total_ventilation.value");
		B47 = eval(theform + ".B47.value");
		B55 = eval(theform + ".B55.value");
		B61 = eval(theform + ".B61.value");
		B64 = eval(theform + ".Total_load_from_other_sources.value");
		BXX = eval(B64) + eval(B61) + eval(B55) + eval(B47) + eval(B42);
		eval(theform).Total_moisture_load.value = Math.round(eval(tol)*BXX)/eval(tol);
		eval(theform + ".B76.focus()");
		document.thisform.choice[0].checked = true;
		firstChoice(theform);
        eval(theform).B7.focus();
		return (true)
	}
	else return (false)

}
	
	
/*	if (calcb13(theform)) {
		if (calcTotLoadWatSurfc(theform)) {
			if (calcTotLoadVent(theform)) {
				if (calcTotLoadPeopl(theform)) {
					if (calcTotLoadWatSurfc(theform)) {
						if (calcProductDying(theform)) {
							B42 = eval(theform + ".Total_ventilation.value");
							B47 = eval(theform + ".B47.value");
							B55 = eval(theform + ".B55.value");
							B61 = eval(theform + ".B61.value");
							B64 = eval(theform + ".Total_load_from_other_sources.value");

							BXX = eval(B64) + eval(B61) + eval(B55) + eval(B47) + eval(B42);
							eval(theform).Total_moisture_load.value = Math.round(eval(tol)*BXX)/eval(tol);
							eval(theform + ".B76.focus()");
							document.thisform.choice[0].checked = true;
							firstChoice(theform);
							return (true)
						}
						else return (false)
					}
					else return (false)
				}
				else return (false)
				}
			else return (false)
		}
		else return (false)
	}
	else return (false)
}
*/

function firstChoice(theform) {
//=IF($B$75=1;$U$26;$AP$26)
	ClearBeforeCalc('document.thisform');
	if (document.thisform.choice[0].checked == true){
		B76=getU26(theform);
		eval(theform).B76.value = B76;
		getRest(theform);
		}
}

function secondChoice(theform) {
//=IF($B$75=1;$U$26;$AP$26)
	ClearBeforeCalc('document.thisform');
	if (document.thisform.choice[1].checked == true)
	{
		B76=getAP26(theform);
		eval(theform).B76.value = B76;
		getRest(theform);
	}
}

function ClearBeforeCalc(theform) {
	eval(theform).B80.value = '';
	eval(theform).B81.value = '';
	eval(theform).B88.value = '';
	eval(theform).B121.value = '';
	eval(theform).B127.value = '';
}

function calcTotMoistLoadC(theform) {
//=C64+C61+C55+C47+C42
				C42 = eval(theform + ".Total_ventilation2.value");
				C47 = eval(theform + ".C47.value");
				C55 = eval(theform + ".C55.value");
				C61 = eval(theform + ".C61.value");
				C64 = eval(theform + ".C64.value");

				CXX = eval(C64) + eval(C61) + eval(C55) + eval(C47) + eval(C42);
				eval(theform).C66.value = Math.round(eval(tol)*CXX)/eval(tol);
		        eval(theform + ".B76.focus()");
				return (true)
}



//================================================================

function calcNeededMoistCont(theform) {
  if ((debug == "on") || (debug == "last")){alert("Slutr„kning startar. F”rst validering av alla inputf„lt:");} 
  if (calcTotMoistLoad(theform)) {
    for (k = 0;  k < 6;  k++) {
      if ((debug == "on") || (debug == "last")){alert("k =" + k);} 
      if (k == 0) {tst = (theform + '.C') } else
      if (k == 1) {tst = (theform + '.D') } else
      if (k == 2) {tst = (theform + '.Precooling_before_dehumidifying') } else
      if (k == 3) {tst = (theform + '.E') } else
      if (k == 4) {tst = (theform + '.F') } else
      if (k == 5) {tst = (theform + '.wet_air_flow') } ;
      if ((debug == "on") || (debug == "last")){alert("Till validator (perc) " + tst);} 
      if (!perc_valid(tst,"40000")) {
        return (false);
        break;
      }
    }
    if ((debug == "on") || (debug == "last")){alert("Validering utf”rd. Ber„kna!");} 
    var B60 = eval(theform + '.C.value');
    var B61 = eval(theform + '.D.value');
    var B62 = eval(theform + '.Precooling_before_dehumidifying.value');
    var B64 = eval(theform + '.E.value');
    var B71 = eval(theform + '.wet_air_flow.value');
    var B74 = eval(theform + '.F.value');
//      622/(B12/EXP(12,03-4025/(B62+235))/1000-1)
    B63 =  622/(B12/Math.exp(12.03-4025/(eval(B62)+235))/1000-1);
    eval(theform).Corresponding_to.value = Math.round(eval(tol)*eval(B63))/eval(tol);
//       B60+B61+B64
    B65 = eval(B60) + eval(B61) + eval(B64);
    eval(theform).A.value = Math.round(eval(tol)*eval(B65))/eval(tol);
//       (B60*B4+B61*B62+B64*B10)/B65
    B68 = (B60*B4+B61*B62+B64*B10)/B65;
    eval(theform).Temperature.value = Math.round(eval(tol)*eval(B68))/eval(tol);
//       (B60*B7+B61*B63+B64*B13)/B65
    B69 = (B60*B7+B61*B63+B64*B13)/B65;
    eval(theform).Moisture_content.value = Math.round(eval(tol)*eval(B69))/eval(tol);
//        B25
    B75 = B25;
    eval(theform).G1.value = Math.round(eval(tol)*eval(B75))/eval(tol);
//        B75+B74+B65-B71
    B76 = eval(B75)+eval(B74)+eval(B65)-eval(B71);
    eval(theform).Total_airflow_to_the_room.value = Math.round(eval(tol)*eval(B76))/eval(tol);
//        B7-1000*(B51-B27)/B76/1.2
    B77 = B7-1000*(B51-B27)/B76/1.2;
    eval(theform).Needed_moisture_content.value = Math.round(eval(tol)*eval(B77))/eval(tol);

//        B65-B71
    B81 = eval(B65)-eval(B71);
    eval(theform).Dry_air_flow.value = Math.round(eval(tol)*eval(B81))/eval(tol);    
//        B75+B81+B74-B60-B24
    B79 = eval(B75)+eval(B81)+eval(B74)-eval(B60)-eval(B24);
    eval(theform).Balance_in_air_changes.value = Math.round(eval(tol)*eval(B79))/eval(tol);

//         (B76*B77-B75*B13-B74*B63)/B81
    B82 = (B76*B77-B75*B13-B74*B63)/B81;
    eval(theform).Needed_moisture_content_in_B.value = Math.round(eval(tol)*eval(B82))/eval(tol);    
    eval(theform).B7.focus();
    return (true);
  }
  else return (false);
}



var ctext= " \#\#\#\#\#\#\#\#\#\#\#\#\#\# \- \¸ Copyright \- \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\n"+
"\n"+
"             \-\- ¸ Copyright AULAB Webdesign 1998 \-\-\-\n"+
" This script is created exclusivly for Seibu Giken DST AB in Sweden,\n"+
"   by Lasse Bergquist, who also owns the Copyright for all JavaScript\-\n"+
"         code in this document. The script itself, however \-\n"+
"               belongs to Seibu Giken DST AB in Sweden\!\n"+
"       You may NOT copy this Java Script Code, or part(s) of it,\n"+
"      to be used elsewhere, with or without modifications, for \n"+
"    any prposes, without permission in writing from both the Script \n"+
"        owner \- Seibu Giken DST AB \- AND the Script author \-\n"+
"       Lasse Bergquist, AULAB Webdesign, contact\@aulab.com .\n"+
"\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-";
