
function getRessourceData(str, row)
{
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="ressources.php";
url=url+"?id="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);



function stateChanged() 
{ 

if (xmlHttp.readyState==1) {
document.getElementById("bezeichnung" + row).value = "wird geladen..."	
}

if (xmlHttp.readyState==2) {
document.getElementById("bezeichnung" + row).value = "wird geladen..."	
}

if (xmlHttp.readyState==3) {
document.getElementById("bezeichnung" + row).value = "wird geladen..."	
}

if (xmlHttp.readyState==4)
{ 


var gotRessourceData = unescape(xmlHttp.responseText);

var splitRessourceData= gotRessourceData.split("|");

document.getElementById("bezeichnung" + row).value=splitRessourceData[0];

if (str==5 || str==30 || str==31 || str==32) {
	
document.getElementById("rwert" + row).value="";
document.getElementById("lambda" + row).value="";
document.getElementById("dicke" + row).readOnly=true;
document.getElementById("dicke" + row).className="invisibleshort";
document.getElementById("lambda" + row).className="invisibleshort";
document.getElementById("rwert" + row).className="invisibleshort";


	
} else {

document.getElementById("lambda" + row).value=splitRessourceData[1];
document.getElementById("dicke" + row).readOnly=false;
document.getElementById("dicke" + row).className="editshort";
document.getElementById("lambda" + row).className="inputshort";
document.getElementById("rwert" + row).className="inputshort";

}






}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

}




function calcAnteil(row) {

	var valueHolz = parseFloat(document.getElementById("holz" + row).value);
	var valueDaemmung = parseFloat(document.getElementById("daemmung" + row).value);
	
	
	
	
	var valueAnteil = Math.round(valueHolz/((valueHolz + valueDaemmung)/100)*100)/100;
		
	if (document.getElementById("daemmung" + row).value == "")	 {
		} else {
		if (document.getElementById("holz" + row).value == "") {
		} else {
		
		
		document.getElementById("anteil" + row).value = valueAnteil;
		}
		}
}



function calcRwert(row) {

	var valueDicke = parseFloat(document.getElementById("dicke" + row).value);
	var valueLambda = parseFloat(document.getElementById("lambda" + row).value);
	
	
	
	
	var valueRwert = Math.round((valueDicke/1000/valueLambda)*1000)/1000;
		
	if (document.getElementById("dicke" + row).value == "")	 {
	
		document.getElementById("rwert" + row).value = "";
	
	
	} else {
		if (document.getElementById("lambda" + row).value == "") {
		
		document.getElementById("rwert" + row).value = "";
		
		} else {
		
		
		
		document.getElementById("rwert" + row).value = valueRwert;
		}
		}
}




function setBelueftung(row) {

	selected = document.getElementById("belueftung" + row).options[document.getElementById("belueftung" + row).selectedIndex].value;
	
	if (selected=="true") {
		document.getElementById("rwert" + row).value = 0.09;
	} else {
		document.getElementById("rwert" + row).value = "";
	}
}




function calcRwertUeb(row) {

	valueLambda = parseFloat(document.getElementById("lambda" + row).value);
	
	valueRwert = 1/valueLambda;
	
	
		if (document.getElementById("txt1").value == "")	 {
		
		
		
			document.getElementById("rwert" + row).value = "";
		
		} else {
			if (document.getElementById("dicke1").value == "") {
			
				document.getElementById("rwert" + row).value = "";
			
			} else {
			
			
				document.getElementById("rwert" + row).value = valueRwert;
			}
		}
		
	
}



function getUwert() {
	
	
	
	document.getElementById("pdflink").style.visibility = 'visible';
	
	var allRwert = 0;

	for (i=1; i<=6; i++) {
		
	if 	(document.getElementById("rwert" + i).value == "") { } else {
		
	rowValue =	parseFloat(document.getElementById("rwert" + i).value);
	
	allRwert = allRwert + rowValue;
	
	//allRwert = Math.round((allRwert + rowValue)*1000)/1000;
	
	
	
	}
	
	
	
	
	
	
	}
	
	allRwertFinal = Math.round((1/(allRwert+0.04+0.125))*1000)/1000;
	
	document.getElementById("uwert").value = allRwertFinal;
	
	
	//alert (allRwert);


}

function createPDF() {
	
	var allVars = '?';
	
	for (v=1; v<=6; v++) {
	
	actId = document.getElementById("txt" + v).value;
	actBez = document.getElementById("bezeichnung" + v).value;
	actDic = document.getElementById("dicke" + v).value;
	actLam = document.getElementById("lambda" + v).value;	
	actRwe = document.getElementById("rwert" + v).value;		
		
	allVars = allVars + "id" + v + "=" + actId + "&bez" + v + "=" + actBez + "&dic" + v + "=" + actDic + "&lam" + v + "=" + actLam + "&rwe" + v + "=" + actRwe + "&";
	}
	
	allVars = allVars + "uwert=" + document.getElementById("uwert").value;
	
	window.open('uwert_print.php' + allVars);
}


