// JavaScript Document
var obj;
var map;
window.onload = function () {
		init();
}
/*window.onunload () = function () {
	if(map)GUnload();
}
*/
function init() {
	map = document.getElementById("map");
	if(map)mapload();
	return true;
}



function mapload() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(53.155211964490505, 8.186682720184326), 7);
		var point = new GLatLng(53.155211964490505, 8.166682720184326);
		map.addOverlay(createMarker(point, 1));
	}
}

function createMarker(point, number) {
  var marker = new GMarker(point);
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml("Leifert-Induction<br />Martin Leifert<br />Marie-Curie-Straße 1<br />26129 Oldenburg<br /><br />Telefon: 0441 - 361 161 90<br />Telefax: 0441 - 361 161 99");
  });
  return marker;
}



function calcIt(o) {
	obj = o;
	window.setTimeout("checkObj()", 100);
	window.setTimeout("calc()", 150);
}
function calcIt2(o) {
	obj = o;
	window.setTimeout("checkObj()", 100);
	window.setTimeout("calc2()", 150);
}
function calcIt3(o) {
	obj = o;
	window.setTimeout("checkObj()", 100);
	window.setTimeout("calc3()", 150);
}
function calcIt4(o) {
	obj = o;
	window.setTimeout("checkObj()", 100);
	window.setTimeout("calc4()", 150);
}
function checkObj() {
	a=obj.value;
	if(a.match(/\.$|,$/))kom=",";
	else kom="";
	if(a=="")a="0.0";
	a=a.replace(/NaN/, "0");
	b=parseFloat(germIn(a));
	obj.value=b.replace(/\./, ",")+kom;
}
function calc() {
	c=document.calculation;
	m=((germIn(c.B5.value)*germIn(c.B5.value))-(germIn(c.B6.value)*germIn(c.B6.value)))*Math.PI*germIn(c.B7.value)*7.86/4000000;
	if(m<0 || isNaN(m))m="Error";
	else m=germOut(m, 2);
	c.out0.value=m;
	
	d=germIn(c.B9.value)*1000000/(germIn(c.B6.value)*11);
	if(d<0 || isNaN(d))d="Error";
	else d=germOut(d, 0);
	c.out1.value=d;
	
	z=0.6*germIn(d)*germIn(m)/germIn(c.B8.value);
	if(z<0 || isNaN(z))z="Error";
	else z=germOut(z,0);
	c.out2.value=z;
	window.setTimeout("calc3()", 150);
}
function calc2() {
	c=document.calculation;
	l=germIn(c.F7.value)*germIn(c.F8.value)*0.6/germIn(c.F9.value);
	if(l<0 || isNaN(l))l="Error";
	else l=germOut(l, 0);
	c.out3.value=l
	window.setTimeout("calc4()", 150);
}

function calc3() {
	c=document.calculation;
	k=germIn(c.B8.value)*germIn(c.out2.value)*germIn(c.B19.value)/3600;
	if(k<0 || isNaN(k))k="Error";
	else k=germOut(k, 2);
	c.out6.value=k;
}

function calc4() {
	c=document.calculation;
	k=germIn(c.out3.value)*germIn(c.F9.value)*germIn(c.F19.value)/3600;
	if(k<0 || isNaN(k))k="Error";
	else k=germOut(k, 2);
	c.out10.value=k;
}


function germIn(a) {
	b=a.replace(/,/, ".");
	return parseFloat(b);
}


function germOut(a, dez) {
	a=a*Math.pow(10, dez);
	a=Math.round(a);
	a=a/Math.pow(10, dez);
	a=a+"";
	b=a.replace(/\./, ",");
	return b;
}
